Submission #337321

# Submission time Handle Problem Language Result Execution time Memory
337321 2020-12-19T17:23:03 Z spatarel Remittance (JOI19_remittance) C++17
0 / 100
1 ms 384 KB
#include <stdio.h>

int main() {
  int n;
  scanf("%d", &n);
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    scanf("%d%d", &a[i], &b[i]);
  }
  int counter = 0;
  for (int i = 0; counter < n; i = (i + 1) % n) {
    int remittance = (a[i] - b[i]) / 2;
    if (remittance > 0) {
      a[i] -= 2 * remittance;
      a[(i + 1) % n] += remittance;
      counter = 0;
    } else {
      counter++;
    }
  }
  bool ok1 = true;
  bool ok2 = true;
  for (int i = 0; i < n; i++) {
    ok1 &= (a[i] == b[i]);
    ok2 &= (a[i] >= 2 && a[i] - 1 == b[i]);
  }
  if (ok1 || ok2) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:5:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    5 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
remittance.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
    9 |     scanf("%d%d", &a[i], &b[i]);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Incorrect 0 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Incorrect 0 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 0 ms 364 KB Output is correct
8 Incorrect 0 ms 364 KB Output isn't correct
9 Halted 0 ms 0 KB -