제출 #279117

#제출 시각아이디문제언어결과실행 시간메모리
279117ChrisT송금 (JOI19_remittance)C++17
100 / 100
416 ms20856 KiB
#include <bits/stdc++.h>
using namespace std;
#define lc ind<<1
#define rc ind<<1|1
const int MN = 1e6 + 5;
int n, a[MN], b[MN];
int main () {
	scanf ("%d",&n);
	long long sumA = 0, sumB = 0;
	for (int i = 0; i < n; i++) {
		scanf ("%d %d",&a[i],&b[i]);
		sumA += a[i]; sumB += b[i];
	}
	bool change = 1;
	while (change) {
		change = 0;
		for (int i = 0; i < n; i++) {
			int diff = a[i] - b[i];
			if (diff <= 0) continue;
			int take = max(diff - (diff&1),2);
			if (a[i] - take < 0) continue;
			if ((sumA - take/2) < sumB) continue;
			change = 1; sumA -= take/2;
			a[i] -= take; a[(i+1)%n] += take/2;
		}
	}
	for (int i = 0; i < n; i++) if (b[i] != a[i]) return !printf ("No\n");
	printf ("Yes\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:11:9: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   11 |   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...