Submission #502542

#TimeUsernameProblemLanguageResultExecution timeMemory
502542talant117408Remittance (JOI19_remittance)C++17
100 / 100
258 ms36352 KiB
/* Code written by Talant I.D. */ #include <bits/stdc++.h> //~ #include <ext/pb_ds/assoc_container.hpp> //~ using namespace __gnu_pbds; using namespace std; typedef long long ll; typedef pair <int, int> pii; typedef pair <ll, ll> pll; //~ typedef tree <ll, null_type, less_equal <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; #define precision(n) fixed << setprecision(n) #define pb push_back #define ub upper_bound #define lb lower_bound #define mp make_pair #define eps (double)1e-9 #define PI 2*acos(0.0) #define endl "\n" #define sz(v) ll((v).size()) #define all(v) v.begin(),v.end() #define rall(v) v.rbegin(),v.rend() #define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define OK cout << "OK" << endl; const ll mod = 998244353 ; ll mode(ll a) { a %= mod; while (a < 0) { a += mod; } return a; } ll subt(ll a, ll b) { return mode(mode(a)-mode(b)); } ll add(ll a, ll b) { return mode(mode(a)+mode(b)); } ll mult(ll a, ll b) { return mode(mode(a)*mode(b)); } ll binpow(ll a, ll b) { ll res = 1; while (b) { if (b&1) res = mult(res, a); a = mult(a, a); b >>= 1; } return res; } int main() { do_not_disturb int n; cin >> n; vector <ll> a(n), b(n); for (int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } int flag = 1; while (flag) { flag = 0; for (int i = 0; i < n; i++) { int tmp = a[i] - b[i]; if (a[i] > b[i]) { if (a[i] >= (tmp+1)/2*2) { a[i] -= (tmp+1)/2*2; a[(i+1)%n] += (tmp+1)/2; flag = 1; } } } } for (int i = 0; i < n; i++) { if (a[i] != b[i]) { cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...