이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6;
const long long INF = 1e17;
int a[MAX_N], b[MAX_N];
int main() {
int n;
cin >> n;
for ( int i = 0; i < n; i++ )
cin >> a[i] >> b[i];
for ( int p = 0; p < 100; p++ ) {
for ( int i = 0; i < n; i++ ) {
if ( a[i] > b[i] ) {
int x = (a[i] - b[i]) / 2;
a[(i + 1) % n] += x;
a[i] -= 2 * x;
}
}
}
bool ans = true;
for ( int i = 0; i < n; i++ )
ans &= (a[i] == b[i]);
cout << (ans ? "YES" : "NO");
for ( int i = 0; i < n; i++ )
printf( "%d %d\n", a[i], b[i] );
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... |