# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
258858 | doowey | Remittance (JOI19_remittance) | C++14 | 1 ms | 384 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;
typedef pair<int,int> pii;
#define fi first
#define se second
#define mp make_pair
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
const int N = (int)1e6 + 10;
ll A[N], B[N];
int main(){
fastIO;
int n;
cin >> n;
for(int i = 0 ; i < n ; i ++ ){
cin >> A[i] >> B[i];
}
bool vso = true;
for(int i = 0 ; i < n; i ++ ){
if(B[i] != 0)
vso = false;
}
if(vso){
vso = true;
for(int i = 0 ; i < n; i ++ ){
if(A[i] != 0)
vso = false;
}
if(vso){
cout << "No\n";
}
else{
cout << "Yes\n";
}
return 0;
}
int nx;
bool has = true;
ll take;
while(has){
has=false;
for(int i = 0 ; i < n; i ++ ){
if(A[i] > B[i]){
take = (A[i] - B[i] + 1) / 2ll;
if(take > 0 && A[i] >= take * 2){
has = true;
A[i] -= take * 2;
A[(i + 1) % n] += take;
}
}
}
}
for(int i = 0 ; i < n; i ++ ){
if(A[i] != B[i]){
cout << "No\n";
return 0;
}
}
cout << "Yes\n";
return 0;
}
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... |