Submission #478028

#TimeUsernameProblemLanguageResultExecution timeMemory
478028LouayFarahRemittance (JOI19_remittance)C++14
15 / 100
1 ms204 KiB
#include "bits/stdc++.h" using namespace std; #define endl "\n" #define ll long long #define pb push_back #define mp make_pair const long long MOD = 1e9+7; const long long INF = 1e18; int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n; cin >> n; vector<ll> a(n, 0), b(n, 0); for(int i = 0; i<n; i++) cin >> a[i] >> b[i]; bool flag2 = false; for(int i = 0; i<n; i++) { if(b[i]!=0) { flag2 = true; break; } } if(!flag2) { bool res = true; for(int i = 0; i<n; i++) { if(a[i]!=0) { res = false; break; } } if(res) cout << "Yes" << endl; else cout << "No" << endl; return 0; } for(int j = 0; j<5; j++) { for(int i = 0; i<n-1; i++) { if(a[i]>b[i]) { ll A = a[i], B = b[i]; ll orig = a[i+1]; a[i+1]+=ceil(double(A-B)/2); orig = a[i+1]-orig; a[i]-=2*orig; } } if(a[n-1]>b[n-1]) { ll A = a[n-1], B = b[n-1]; ll orig = a[0]; a[0]+=ceil(double(A-B)/2); orig = a[0]-orig; a[n-1]-=2*orig; } } bool flag = true; for(int i = 0; i<n; i++) { if(a[i]!=b[i]) { flag = false; break; } } if(flag) cout << "Yes" << endl; else cout << "No" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...