Submission #1091529


Source Code Expand

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define sz(s) ((int) ((s).size()))

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

typedef long long ll;
typedef long double ld;

const int inf = (int) 1.01e9;
const ld eps = 1e-11;
const ld pi = acos(-1.0L);

mt19937 mrand(random_device{} ());
int rnd(int x) {
  return mrand() % x;
}

const int mod = (int) 1e9 + 7;

void add(int & x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int sum(int x, int y) {
  add(x, y);
  return x;
}

int mult(int x, int y) {
  return (ll) x * y % mod;
}

int power(int x, ll p) {
  int res = 1;
  while (p) {
    if (p & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
    p >>= 1;
  }
  return res;
}

void precalc() {
}

int n;
int cnt[2];

bool read() {
  if (scanf("%d", &n) < 1) {
    return false;
  }
  memset(cnt, 0, sizeof(cnt));
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    cnt[a & 1]++;
  }
  return true;
}

void solve() {
  cnt[0] += cnt[1] / 2;
  cnt[1] = cnt[1] % 2;
  if (cnt[0] && cnt[1]) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
}

int main() {
  precalc();
#ifdef DEBUG
  assert(freopen("text.in", "r", stdin));
  assert(freopen("text.out", "w", stdout));
#endif

  while (read()) {
    solve();
#ifdef DEBUG
    eprintf("Time: %.3f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}

Submission Info

Submission Time
Task A - Addition
User StanislavErshov
Language C++14 (GCC 5.4.1)
Score 300
Code Size 1618 Byte
Status AC
Exec Time 14 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘bool read()’:
./Main.cpp:73:20: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &a);
                    ^

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 2
AC × 14
Set Name Test Cases
Sample sample1.txt, sample2.txt
All sample1.txt, sample2.txt, in1.txt, in10.txt, in11.txt, in12.txt, in2.txt, in3.txt, in4.txt, in5.txt, in6.txt, in7.txt, in8.txt, in9.txt
Case Name Status Exec Time Memory
in1.txt AC 14 ms 256 KB
in10.txt AC 14 ms 256 KB
in11.txt AC 3 ms 256 KB
in12.txt AC 3 ms 256 KB
in2.txt AC 14 ms 256 KB
in3.txt AC 14 ms 256 KB
in4.txt AC 14 ms 256 KB
in5.txt AC 14 ms 256 KB
in6.txt AC 14 ms 256 KB
in7.txt AC 14 ms 256 KB
in8.txt AC 14 ms 256 KB
in9.txt AC 14 ms 256 KB
sample1.txt AC 3 ms 256 KB
sample2.txt AC 3 ms 256 KB