이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define yes { cout << "Yes\n"; exit(0); }
#define no { cout << "No\n"; exit(0); }
using namespace std;
const int Nmax = 1e6 + 5;
typedef long long ll;
int n, a[Nmax], b[Nmax];
int main()
{
// freopen("rem.in", "r", stdin);
cin.tie(0); cin.sync_with_stdio(false);
int i, j;
ll s1 = 0, s2 = 0;
cin >> n;
for(i=1; i<=n; ++i) cin >> a[i] >> b[i], s1 += a[i], s2 += b[i];
for(i = s1 - s2; i >= 0; --i)
{
for(j=1; j<=n; ++j)
if(a[j] > b[j]) break;
if(i == 0)
{
if(j == n+1) yes
else no
}
a[j] -= 2;
if(j < n) a[j+1] ++;
else a[1] ++;
}
no
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... |