Submission #1295516

#TimeUsernameProblemLanguageResultExecution timeMemory
1295516baotoan655Remittance (JOI19_remittance)C++20
100 / 100
152 ms16340 KiB
#include <bits/stdc++.h> #define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); } using namespace std; #define int long long int n; const int N = 1e6 + 5; pair<int, int> arr[1000005]; const int MAXC = 1e9; void dfs(int u, int x) { arr[u].first += x; if(arr[u].first <= arr[u].second) return; int t = (arr[u].first - arr[u].second + 1) / 2; if(arr[u].first < t * 2) return; arr[u].first -= t << 1; dfs((u + 1) % n, t); } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); // file("A") else file("task"); cin >> n; for(int i = 0; i < n; ++i) cin >> arr[i].first >> arr[i].second; for(int i = 0; i < n; ++i) dfs(i, 0); bool flag = true; for(int i = 0; i < n; ++i) if(arr[i].first != arr[i].second) flag = 0; if(flag) cout << "Yes\n"; else cout << "No\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...