# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
433981 | ismoilov | Remittance (JOI19_remittance) | C++14 | 1 ms | 204 KiB |
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>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
void S()
{
int n;
cin >> n;
vector <int> a(n);
fp(i,0,n){
int x, y;
cin >> x >> y;
a[i] = x - y;
}
bool yes = 0;
fp(i,0,n){
if(a[i]%2==1 || a[i] < 0)
continue;
int s = a[i];
a[i] = 0;
bool ok = 1;
fp(j,0,n){
if(a[(i+j)%n] + s < 0){
ok = 0;
// cout << i << " " << j << " " << s << "\n";
break;
}
s += a[(i+j)%n];
if(s % 2 == 1){
ok = 0;
break;
}
s /= 2;
}
yes |= (ok && s==0);
}
cout << (yes ? "Yes" : "No");
}
int main()
{
IOS;
S();
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |