제출 #1121437

#제출 시각아이디문제언어결과실행 시간메모리
1121437Pacybwoah송금 (JOI19_remittance)C++17
0 / 100
2 ms596 KiB
#include<iostream> #include<vector> using namespace std; typedef long long ll; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector<ll> vec(n); ll sum = 0; for(int i = 0; i < n; i++){ ll a, b; cin >> a >> b; vec[i] = a - b; sum += vec[i]; } int ca = 0, cb = 1; while(sum > 0){ if(vec[ca] > 0){ if(vec[ca] & 1){ sum -= (vec[ca] + 1) / 2; vec[cb] += (vec[ca] + 1) / 2; vec[ca] = -1; } else{ sum -= vec[ca] / 2; vec[cb] += vec[ca] / 2; vec[ca] = 0; } } ca++; cb++; if(cb == n) cb = 0; if(ca == n) ca = 0; } for(int i = 0; i < n; i++){ if(vec[i] != 0){ cout << "No\n"; return 0; } } cout << "Yes\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...