Submission #431680

#TimeUsernameProblemLanguageResultExecution timeMemory
431680kostia244Virus Experiment (JOI19_virus)C++17
0 / 100
10 ms332 KiB
#pragma GCC optimize("trapv") #include<bits/stdc++.h> using namespace std; const int N = 1e6 + 16; int n, a[N], b[N]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 0; i < n; i++) { cin >> a[i] >> b[i]; } for(int z = 100; z--;){ for(int i = 0; i+1 < n; i++) { if(a[i] > b[i]) { a[i+1] += (a[i]-b[i]+1)/2; a[i] -= 2*((a[i]-b[i]+1)/2); } } if(a[n-1] > b[n-1]) { a[0] += (a[n-1]-b[n-1]+1)/2; a[n-1] -= 2*((a[n-1]-b[n-1]+1)/2); } } int ok = 1; for(int i = 0; i < n; i++) ok &= a[i] == b[i]; cout << (ok?"Yes":"No") << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...