Submission #163917

#TimeUsernameProblemLanguageResultExecution timeMemory
163917maruiiRemittance (JOI19_remittance)C++14
100 / 100
332 ms8976 KiB
#include <bits/stdc++.h> using namespace std; using pii = pair<int, int>; #define ff first #define ss second int N, A[1000006], X[1000006]; int main() { ios_base::sync_with_stdio(0), cin.tie(0); cin >> N; for (int i = 1; i <= N; ++i) { int x; cin >> x >> X[i]; A[i] = x - X[i]; } for (int i = 1; i <= N; ++i) { int t = i; while (A[t] > 1) { int a = A[t] / 2; A[t] -= a * 2; A[t % N + 1] += a; t = t % N + 1; } } int flag = 1, flag2 = 0, flag3 = 1; for (int i = 1; i <= N; ++i) { if (A[i]) flag3 = 0; if (A[i] != 1) flag = 0; if (X[i]) flag2 = 1; } if ((flag && flag2) || flag3) puts("Yes"); else puts("No"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...