Submission #292158

#TimeUsernameProblemLanguageResultExecution timeMemory
292158muhammad_hokimiyonRemittance (JOI19_remittance)C++14
100 / 100
303 ms35448 KiB
#include <bits/stdc++.h> #define fi first #define se second #define ll long long #define dl double long using namespace std; const int N = 1e6 + 7; const int M = 20 + 7; const ll mod = 1e9 + 7; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int n; ll a[N]; ll b[N]; int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); //freopen( "input.txt" , "r" , stdin ); //freopen( "output.txt" , "w" , stdout ); cin >> n; for( int i = 0; i < n; i++ ){ cin >> a[i] >> b[i]; } for( int it = 0; it < 35; it++ ){ for( int i = 0; i < n; i++ ){ if( a[i] > b[i] && a[i] > 1 ){ int nx = (i + 1) % n; ll cost = (a[i] - b[i]) / 2; cost = max( cost , 1ll ); a[nx] += cost; a[i] -= cost * 2; } } } bool f = true; for( int i = 0; i < n; i++ )f &= (a[i] == b[i]); cout << (f ? "Yes" : "No"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...