Submission #1255979

#TimeUsernameProblemLanguageResultExecution timeMemory
1255979namhh송금 (JOI19_remittance)C++20
0 / 100
0 ms320 KiB
#include <bits/stdc++.h> using namespace std; #define pii pair<int,int> #define fi first #define se second const int N = 1e6+5; const int block = 650; int n,a[N],b[N]; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 1; i <= n; i++) cin >> a[i] >> b[i]; for(int i = 0; i < 30; i++){ for(int j = 1; j <= n; j++){ if(a[j] > b[j]+1){ int x = (a[j]-b[j])/2; a[j] -= 2*x; a[(j+1) % n] += x; } } } for(int i = 1; i <= n; i++){ if(a[i] != b[i]){ cout << "NO"; return 0; } } cout << "YES"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...