Submission #933174

#TimeUsernameProblemLanguageResultExecution timeMemory
933174De3b0oRemittance (JOI19_remittance)C++14
100 / 100
475 ms83500 KiB
#include<bits/stdc++.h> #define ll long long #define F first #define S second #define in insert #define er erase #define pb push_back #define ppb pop_back() #define ph push #define pp pop() #define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define cans cout << ans << "\n"; #define yes cout << "Yes" << "\n"; #define no cout << "No" << "\n"; #define pll pair<ll,ll> #define lin cout << "\n"; #define sqr 340 #define mod 1000000007 #define mid ((l+r)/2) using namespace std; ll fp(ll x , ll y) { if(y==0) return 1; ll z = fp(x,y/2); if(y&1) return z*z*x; else return z*z; } int sqrot(ll x) { int l = 0 , r = INT_MAX; while(l<=r) { if(mid*mid>=x) r=mid-1; else l=mid+1; } return r+1; } ll cel(ll x , ll y) { return x/y + bool(x%y); } string tb(ll x) { string s = ""; while(x>0) { if(x&1) s+='1'; else s+='0'; x/=2; } while(s.size()<60) s+='0'; return s; } ll fb(string s) { ll x = 0; ll c = 1; for(int8_t i = 0 ; 60>i ; i++) { if(s[i]=='1') x+=c; c*=2; } return x; } int main() { d3 ll n; cin >> n; ll a[n+1]; ll b[n+1]; for(int i = 1 ; n>=i ; i++) cin >> a[i] >> b[i]; set<ll> s; for(int i = 1 ; n>=i ; i++) if(a[i]>b[i]&&a[i]>1) s.in(i); while(!s.empty()) { auto it = s.begin(); ll x = *it; ll y = x+1; if(x==n) y=1; a[y]+=cel(a[x]-b[x],2); a[x]-=cel(a[x]-b[x],2)*2; if(a[x]<0) { a[x]+=2; a[y]-=1; } if(a[y]>b[y]&&a[y]>1) s.in(y); s.erase(it); } bool l = 1; for(int i = 1 ; n>=i ; i++) if(a[i]!=b[i]) l=0; if(l) yes else no }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...