Submission #552094

#TimeUsernameProblemLanguageResultExecution timeMemory
552094RaresFelixRemittance (JOI19_remittance)C++17
100 / 100
215 ms16024 KiB
#include <bits/stdc++.h> #define MN 1000011 #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") using ll = long long; using namespace std; ll n, A[MN], B[MN]; int main() { cin.tie(0)->sync_with_stdio(0); cin >> n; for(int i = 1; i <= n; ++i) cin >> A[i] >> B[i]; int ok; do { ok = 0; for(int i = 1; i <= n; ++i) { if(A[i] > B[i]) { ll v; ok = 1, v = (A[i] - B[i] + 1) >> 1; if(A[i] < (v << 1)) --v; if(!v) ok = 0; A[i + 1] += v; A[i] -= v << 1; } } A[1] += A[n + 1]; A[n + 1] = 0; } while(ok); ok = 1; for(int i = 1; i <= n; ++i) if(A[i] != B[i]) ok = 0; cout << (ok ? "Yes\n" : "No\n"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...