제출 #431622

#제출 시각아이디문제언어결과실행 시간메모리
431622ScarletS송금 (JOI19_remittance)C++17
0 / 100
2 ms204 KiB
#include <bits/stdc++.h> #define ll long long #define sz(x) (int)(x).size() using namespace std; int a[1<<20][2]; priority_queue<array<int,2>> o,e; void add(int i) { if (a[i][0]>a[i][1]) { if ((a[i][0]-a[i][1])&1) o.push({a[i][0]-a[i][1],i}); else e.push({a[i][0]-a[i][1],i}); } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n,x,y; cin>>n; for (int i=0;i<n;++i) { cin>>a[i][0]>>a[i][1]; add(i); } while (!e.empty()) { x=e.top()[0]; y=e.top()[1]; e.pop(); if (a[y][0]-a[y][1]!=x) continue; a[(y+1)%n][0]+=x/2; a[y][0]=a[y][1]; add((y+1)%n); } for (int i=0;i<n;++i) if (a[i][0]!=a[i][1]) { cout<<"No"; return 0; } cout<<"Yes"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...