Submission #807349

#TimeUsernameProblemLanguageResultExecution timeMemory
807349Jarif_RahmanRemittance (JOI19_remittance)C++17
0 / 100
1 ms316 KiB
#include <bits/stdc++.h> #define pb push_back #define f first #define sc second using namespace std; typedef long long int ll; typedef string str; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); int n; cin >> n; vector<ll> A(n), B(n); for(int i = 0; i < n; i++) cin >> A[i] >> B[i]; queue<int> Q; vector<bool> inQ(n, 0); for(int i = 0; i < n; i++) if(A[i] > B[i]+1) inQ[i] = 1, Q.push(i); while(!Q.empty()){ int i = Q.front(); Q.pop(); inQ[i] = 0; int x = (A[i]-B[i])/2; A[i] = B[i]+(A[i]-B[i])%2; int j = (i+1)%n; if(A[j] <= B[j]+1 && A[j]+x > B[j]+1) inQ[j] = 1, Q.push(j); A[j]+=x; } bool a = 1, b = 1; for(int i = 0; i < n; i++){ if(A[i] != B[i]) a = 0; if(A[i] != B[i]+1) b = 0; } cout << (a|b?"Yes\n":"No\n"); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...