Submission #252850

# Submission time Handle Problem Language Result Execution time Memory
252850 2020-07-26T10:55:04 Z amiratou Remittance (JOI19_remittance) C++14
0 / 100
1 ms 384 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ld long double
#define ll long long
//#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int A[1000006],B[1000006],bal[1000006],n,r;
bool solve(int idx,int m){
    if(idx==r){
        if(!m)return 1;
        return 0;
    }
    if(((bal[idx]+m) < 0) || ((m+bal[idx])&1))
        return 0;
    return solve((idx+1)%n,(m+bal[idx])>>1);
}
int32_t main(){
    boost;
    //freopen(".in","r",stdin);
    cin>>n;
    for (int i = 0; i < n; ++i){
        cin>>A[i]>>B[i];
        bal[i]=A[i]-B[i];
    }
    for (int i = 0; i < n; ++i)
        if((bal[i]>=0) && !(bal[i]&1)){
            r=i;
            if(solve((i+1)%n,bal[i]/2)){
                cout<<"Yes\n";
                return 0;
            }
        }
    cout<<"No\n";
    return 0;
}

//do smth instead of nothing and stay organized
//long long
//array bounds
//special cases
//binary search
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 380 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 380 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 380 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 0 ms 384 KB Output is correct
8 Incorrect 0 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -