Submission #434065

#TimeUsernameProblemLanguageResultExecution timeMemory
434065AzimjonRemittance (JOI19_remittance)C++17
0 / 100
1 ms324 KiB
// Muallif: Azimjon Mehmonali o'g'li #include <bits/stdc++.h> using namespace std; #define int long long const long double PI = 3.1415926535897; const int mod = 1000000007LL; const int INF = 1e18; const int N = 100; signed main() { ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<int> a(n + 1), b(n + 1); for (int i = 1; i <= n; i++) { cin >> a[i] >> b[i]; } pair<int, int> p{-1, -1}; for (int i = 1; i <= n; i++) { p = max(p, make_pair(a[i] - b[i], i)); } int t = 10; while (t--) { for (int i = p.second; i < n; i++) { if (a[i] < b[i]) continue; int z = a[i] - b[i]; z /= 2; a[i] -= 2 * z; a[i + 1] += z; } int z = a[n] - b[n]; z /= 2; a[n] -= 2 * z; a[1] += z; for (int i = 1; i < p.second; i++) { if (a[i] < b[i]) continue; int z = a[i] - b[i]; z /= 2; a[i] -= 2 * z; a[i + 1] += z; } } if (a == b) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...