Submission #291837

#TimeUsernameProblemLanguageResultExecution timeMemory
291837maximath_1Remittance (JOI19_remittance)C++11
100 / 100
267 ms28700 KiB
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <string.h>
#include <set>
#include <math.h>
#include <numeric>
#include <assert.h>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <queue>
using namespace std;
#define ll long long
#define ld long double
#define endl "\n"
const ll inf = 1e9 + 69;
const ld pi = 3.14159265358979323L;
const ld eps = 1e-15;
const int N = 1e5 + 5;

void setIn(string s){freopen(s.c_str(), "r", stdin);}
void setOut(string s){freopen(s.c_str(), "w", stdout);}
void unsyncIO(){cin.tie(0) -> sync_with_stdio(0);}
void setIO(string s = ""){
	unsyncIO();
	if(s.size()){
		setIn(s + ".in");
		setOut(s + ".out");
	}
}

int n, a[1000005], b[1000005];

int main(){
	setIO();

	cin >> n;
	for(int i = 0; i < n; i ++)
		cin >> a[i] >> b[i];

	for(bool done = 0; !done;){
		done = 1;
		for(int i = 0; i < n; i ++){
			if(a[i] > 1 && a[i] > b[i]){
				int x = max(1, (a[i] - b[i]) / 2);
				a[i] -= x * 2;
				a[(i + 1) % n] += x;
				done = 0;
			}
		}
	}

	bool ok = 1;
	for(int i = 0; i < n; i ++)
		if(a[i] != b[i]) ok = 0;

	if(ok) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Compilation message (stderr)

remittance.cpp: In function 'void setIn(std::string)':
remittance.cpp:25:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   25 | void setIn(string s){freopen(s.c_str(), "r", stdin);}
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
remittance.cpp: In function 'void setOut(std::string)':
remittance.cpp:26:30: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)', declared with attribute warn_unused_result [-Wunused-result]
   26 | void setOut(string s){freopen(s.c_str(), "w", stdout);}
      |                       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...