Submission #135052

#TimeUsernameProblemLanguageResultExecution timeMemory
135052baluteshihRemittance (JOI19_remittance)C++14
100 / 100
342 ms16156 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> #define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); #define pb push_back #define ET cout << "\n" #define ALL(v) v.begin(),v.end() #define MP make_pair #define F first #define S second #define MEM(i,j) memset(i,j,sizeof i) #define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;} using namespace std; typedef long long ll; typedef pair<int,int> pii; typedef pair<ll,ll> pll; ll n; pll arr[1000005]; const ll MAXC=1e9; void dfs(ll u,ll x) { arr[u].F+=x; if(arr[u].F<=arr[u].S) return; ll t=(arr[u].F-arr[u].S+1)/2; if(arr[u].F<t*2) return; arr[u].F-=t<<1; dfs((u+1)%n,t); } int main() {jizz ll flag=1; cin >> n; for(int i=0;i<n;++i) cin >> arr[i].F >> arr[i].S; for(int i=0;i<n;++i) dfs(i,0); for(int i=0;i<n;++i) if(arr[i].F!=arr[i].S) flag=0; if(flag) cout << "Yes\n"; else cout << "No\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...