제출 #252994

#제출 시각아이디문제언어결과실행 시간메모리
252994amiratou송금 (JOI19_remittance)C++17
100 / 100
313 ms36476 KiB
#pragma GCC optimize("O3") #include <bits/stdc++.h> using namespace std; #define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0) #define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()) #define fi first #define se second #define debug(x) cerr << " - " << #x << ": " << x << endl; #define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl; #define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl; #define sep() cerr << "--------------------" << endl; #define all(x) (x).begin(),(x).end() #define sz(x) (ll)x.size() #define ld long double #define ll long long #define int ll #define ii pair<int,int> #define v vector<int> #define vii vector<ii> #define vv vector<vector<int> > #define mp make_pair #define INF 1000000000 #define pb push_back #define EPS 1e-9 const int MOD = 1000000007; // 998244353 int A[1000006],B[1000006],bal[1000006],ans[1000006],n,r,sum=0; void out(){ cout<<"No\n"; exit(0); } int32_t main(){ boost; //freopen(".in","r",stdin); cin>>n; bool k=1,k2=1; for (int i = 0; i < n; ++i){ cin>>A[i]>>B[i]; if(B[i]>0)k=0; if(A[i]>0)k2=0; } if(k&&k2){cout<<"Yes\n";return 0;} else if(k)out(); while(1){ bool f=0; for (int i = 0; i < n; ++i) if(A[i]>B[i]){ int val=(A[i]-B[i]+1)>>1; A[i]-=2*val; A[(i+1)%n]+=val; f=1; } if(!f)break; } for (int i = 0; i < n; ++i) if(A[i]!=B[i])out(); cout<<"Yes\n"; return 0; } //do smth instead of nothing and stay organized //long long //array bounds //special cases //binary search
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...