제출 #610974

#제출 시각아이디문제언어결과실행 시간메모리
610974Plurm송금 (JOI19_remittance)C++11
100 / 100
299 ms12832 KiB
#include <bits/stdc++.h>
using namespace std;

int a[1000005];
int b[1000005];
int main() {
  int n;
  scanf("%d", &n);
  bool idenzeroa = true;
  bool idenzerob = true;
  for (int i = 1; i <= n; i++) {
    scanf("%d%d", a + i, b + i);
    if (a[i])
      idenzeroa = false;
    if (b[i])
      idenzerob = false;
  }
  if (idenzerob) {
    printf(idenzeroa ? "Yes\n" : "No\n");
    return 0;
  }
  for (int it = 0; it < 100; it++) {
    for (int i = 1; i <= n; i++) {
      if (a[i] > b[i]) {
        int transfer = (a[i] - b[i] + 1) / 2;
        a[i] -= 2 * transfer;
        a[i % n + 1] += transfer;
      }
    }
  }
  bool ok = true;
  for (int i = 1; i <= n; i++) {
    if (a[i] != b[i])
      ok = false;
  }
  printf(ok ? "Yes\n" : "No\n");
  return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

remittance.cpp: In function 'int main()':
remittance.cpp:8:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    8 |   scanf("%d", &n);
      |   ~~~~~^~~~~~~~~~
remittance.cpp:12:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |     scanf("%d%d", a + i, b + i);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...