Submission #311719

# Submission time Handle Problem Language Result Execution time Memory
311719 2020-10-11T06:27:27 Z mohamedsobhi777 Remittance (JOI19_remittance) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>


#pragma GCC optimize("-Ofast")
#pragma GCC optimize("trapv")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx2,tune=native")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-funroll-loops")

#define I inline void 
#define S struct 
#define vi vector<int> 
#define vii vector<pair<int,int>>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std ; 
using ll = long long ; 
using ld = long double ; 

const int N = 1e6 + 7 , mod = 1e9 + 7 ; 
const ll inf = 2e18 ; 

// How interesting!

int n ; 
ll A[N] ; 

int main(){
        ios_base::sync_with_stdio(0) ;
        cin.tie(0) ; 
        //freopen("in.in" , "r" , stdin) ; 
        cin >> n; 
        priority_queue<pair<int,int>>q ; 
        for(int i = 0 ; i < n ; ++ i){
                ll a , b ; 
                cin >> a >> b;
                //q.push({a-b , i}) ; 
                A[i] = a - b ; 
        } 
        while(1){
                bool ok = 0 ; 
                for(int i = 0 ;i < n; ++ i){
                        if(A[i] > 1){
                                A[(i+1)%n]+=A[i]/2;
                                A[i]%=2;
                                ok = 1; 
                                break ; 
                        }
                }
                if(!ok)break ; 
        }       
        for(int i = 0 ;i < n; ++ i){
                if(A[i] != 0)
                        return cout<<"No", 0 ; 
        }
        cout<<"Yes" ; 
        /*int k = 0 ; 
        while(q.size()){
                int x = q.top().first ; 
                int y = q.top().second ; 
                assert(k ++ < 1000000) ; 
                q.pop() ; 
                if(A[y] != x){
                        q.push({A[y] , y}) ; 
                        continue ; 
                }
                if(x == 1 || x == 0)continue ; 
                if(x < 0)return cout<<"No" , 0 ; 
                A[(y+1)%n]+=x/2;
                q.push({A[(y+1)%n],(y+1)%n}) ;
                A[y] %=2 ; 
        }
        for(int i = 0 ;i < n; ++ i)
                if(A[i] < 0)
                        return cout<<"No" , 0 ; 
        cout<<"Yes" ;*/
        return 0 ; 
}

/*
        - bounds sir (segtree = 4N, eulerTour = 2N, ...)
        - a variable defined twice?
        - will overflow?
        - is it a good complexity?
        - don't mess up indices (0-indexed vs 1-indexed)
        - reset everything between testcases. 
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 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 384 KB Output is correct
6 Correct 0 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Incorrect 1 ms 384 KB Output isn't correct
9 Halted 0 ms 0 KB -