제출 #489539

#제출 시각아이디문제언어결과실행 시간메모리
489539fhvirusRemittance (JOI19_remittance)C++17
100 / 100
312 ms11972 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; #define ff first #define ss second #define pb emplace_back #define AI(x) begin(x),end(x) template<class I> bool chmin(I&a, I b){ return a > b ? (a=b, true) : false; } template<class I> bool chmax(I&a, I b){ return a < b ? (a=b, true) : false; } #ifdef OWO #define debug(args...) LKJ("\033[1;32m[ " + string(#args) + " ]\033[0m", args) template<class I> void LKJ(I&&x){ cerr << x << endl; } template<class I, class...T> void LKJ(I&&x, T&&...t){ cerr << x << ", "; LKJ(t...); } template<class I> void OI(I a, I b){ while(a < b) cerr << *a << " \n"[next(a) == b], ++a; } #else #define debug(...) 0 #define OI(...) 0 #endif const int kN = 1000001; const int kL = 30; int N, A[kN], B[kN]; void gg(){ cout << "No\n"; exit(0); } void good(){ cout << "Yes\n"; exit(0); } void input(){ cin >> N; for(int i = 1; i <= N; ++i) cin >> A[i] >> B[i]; } int nxt(int i){ return i == N ? 1 : i+1; } void solve(){ for(int k = 0; k < 20; ++k){ for(int i = 1; i <= N; ++i){ if(A[i] > B[i]){ int t = A[i] - B[i]; if(t & 1) --t; A[ nxt(i) ] += (t>>1); A[i] -= t; } } } bool all = true; for(int i = 1; i <= N; ++i) all &= (A[i] == B[i]); if(all) good(); all = true; for(int i = 1; i <= N; ++i) all &= (A[i] == B[i]+1); if(all and *max_element(A+1, A+N+1) > 1) good(); gg(); return; } signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); input(); solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...