Submission #428730

#TimeUsernameProblemLanguageResultExecution timeMemory
428730abdzagRemittance (JOI19_remittance)C++17
100 / 100
802 ms36428 KiB
#include<bits/stdc++.h> #include<unordered_map> #include<unordered_set> #define rep(i,a,b) for(int i=int(a);i<int(b);i++) #define rrep(i,a,b) for(int i=int(a);i>int(b);i--) #define trav(a,v) for(auto& a: v) #define sz(v) v.size() #define all(v) v.begin(),v.end() #define vi vector<int> typedef long long ll; typedef long double ld; typedef unsigned long long ull; const long long inf = 2e9; using namespace std; int main() { cin.sync_with_stdio(false); ll n; cin >> n; vector<ll> a(n); vector<ll> b(n); rep(i, 0, n)cin >> a[i] >> b[i]; rep(i, 0, n*50) { ll ind = i % n; ll nxt = (i + 1) % n; if (a[ind] <= b[ind])continue; ll change = a[ind] - b[ind]; change += change % 2; if (a[ind] < change)continue; a[nxt] += change/2; a[ind] -= change; } if (a == b)cout << "Yes"; else cout << "No"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...