This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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... |