제출 #1260715

#제출 시각아이디문제언어결과실행 시간메모리
1260715mingga송금 (JOI19_remittance)C++20
0 / 100
0 ms320 KiB
// Author: caption_mingle
#include "bits/stdc++.h"

using namespace std;

#define ln "\n"
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define int long long
const int mod = 1e9 + 7;
const int inf = 2e9;
const int N = 1e6 + 7;
int n, a[N], b[N], nxt[N];

signed main() {
	cin.tie(0) -> sync_with_stdio(0);
	#define task ""
	if(fopen(task ".INP", "r")) {
		freopen(task ".INP", "r", stdin);
		freopen(task ".OUT", "w", stdout);
	}
	cin >> n;
	int tota = 0, totb = 0;
	for(int i = 1; i <= n; i++) {
		cin >> a[i] >> b[i];
		tota += a[i];
		totb += b[i];
		nxt[i] = i + 1;
		if(i == n) nxt[i] = 1;
	}
	if(tota < totb) cout << "No";
	else {
		int ext = tota - totb;
		while(ext > 0) {
			for(int i = 1; i <= n; i++) {
				if(a[i] > b[i] and (a[i] - b[i]) % 2 == 0) {
					int t = (a[i] - b[i]) / 2;
					a[i] -= 2 * t;
					a[nxt[i]] += t;
					ext -= t;
 				}
			}
		}
	}
	bool ok = 1;
	for(int i = 1; i <= n; i++) {
		if(a[i] != b[i]) {
			ok = 0;
			break;
		}
	}
	if(ok) cout << "Yes";
	else cout << "No";
    cerr << "\nTime: " << clock() * 1000 / CLOCKS_PER_SEC;
}

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

remittance.cpp: In function 'int main()':
remittance.cpp:22:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |                 freopen(task ".INP", "r", stdin);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp:23:24: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |                 freopen(task ".OUT", "w", stdout);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...