제출 #1024959

#제출 시각아이디문제언어결과실행 시간메모리
1024959vjudge1송금 (JOI19_remittance)C++17
100 / 100
165 ms32592 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define ld long double #define pii pair<int, int> #define pll pair<ll, ll> #define pld pair<ld, ld> #define pb push_back #define fi first #define se second #define debug(x) cout << #x << " => " << x << endl #define all(x) x.begin(),x.end() int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int n;cin>>n; int a[n],b[n],c[n]; for(int i=0;i<n;i++) cin>>a[i]>>b[i]; for(int i=0;i<n;i++) c[i]=a[i]-b[i]; int i=0,cnt=0; while(cnt!=n+1) { if(c[i]<=1) cnt++; else c[(i+1)%n]+=(c[i]/2),c[i]%=2,cnt=0; if(c[i]==1 && b[i]!=0)c[i]-=2,c[(i+1)%n]+=1,cnt=0; i=(i+1)%n; } bool ok=1; for(i=0;i<n;i++) if(c[i]!=0) ok=0; cout<<(ok?"Yes":"No"); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...