제출 #208628

#제출 시각아이디문제언어결과실행 시간메모리
208628super_j6송금 (JOI19_remittance)C++14
100 / 100
306 ms17516 KiB
#include <iostream> #include <cstdio> #include <algorithm> using namespace std; #define endl '\n' #define pi pair<int, int> const int maxn = 1000000; int n; int a[maxn], b[maxn]; int main(){ ios::sync_with_stdio(false); cin.tie(NULL); cin >> n; for(int i = 0; i < n; i++) cin >> a[i] >> b[i]; for(int i = 0, j = 0; j <= n; i++, i %= n, j++){ if(!(a[i] == 1 && !b[i]) && a[i] > b[i]){ int d = a[i] - b[i]; d += d & 1; d -= 2 * (d > a[i]); a[(i + 1) % n] += d >> 1; a[i] -= d; j = 0; } } for(int i = 0; i < n; i++){ if(a[i] != b[i]){ cout << "No" << endl; return 0; } } cout << "Yes" << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...