Submission #1260719

#TimeUsernameProblemLanguageResultExecution timeMemory
1260719minggaRemittance (JOI19_remittance)C++20
0 / 100
0 ms328 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 {
		for(int t = 0; t < 80; t++) {
			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] + 1) / 2;
					a[i] -= 2 * t;
					a[nxt[i]] += 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;
}

Compilation message (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...