이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define mp make_pair
#define X first
#define Y second
using namespace std;
typedef long long ll;
typedef pair <int, int> ii;
const int N = 1e6 + 1;
int n, a[N], b[N];
void readInput(){
cin >> n;
for(int i = 1; i <= n; i++)
cin >> a[i] >> b[i];
}
void solve(){
while (1){
bool flag = 1;
for(int i = 1; i <= n; i++)
if (a[i] > b[i]){
int cnt = (a[i] - b[i] + (b[i] > 0)) / 2;
a[i] -= cnt * 2;
a[i % n + 1] += cnt;
if (cnt > 0)
flag = 0;
}
if (flag)
break;
}
for(int i = 1; i <= n; i++)
if (a[i] != b[i]){
cout << "No";
return;
}
cout << "Yes";
}
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
readInput();
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |