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 <iostream>
using namespace std;
int n, a[25], b[25];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i=1; i<=n; i++)
cin >> a[i] >> b[i];
bool ok = true;
while(ok){
ok = false;
for(int i=1; i<=n; i++)
if(a[i] > b[i] && a[i] > 1){
ok = true;
int dif = (a[i] - b[i] + 1) / 2;
if(i == n)
a[1] += dif;
else
a[i+1] += dif;
a[i] -= 2 * dif;
break;
}
}
ok = true;
for(int i=1; i<=n; i++)
if(a[i] != b[i])
ok = false;
if(ok)
cout << "Yes" << '\n';
else
cout << "No" << '\n';
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... |