Submission #253754

# Submission time Handle Problem Language Result Execution time Memory
253754 2020-07-28T16:02:34 Z kshitij_sodani Remittance (JOI19_remittance) C++14
0 / 100
0 ms 384 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long llo;
#define mp make_pair
#define pb push_back
#define a first 
#define b second
llo n;
pair<llo,llo> it[100001];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;

	for(llo i=0;i<n;i++){
		cin>>it[i].a>>it[i].b;
	}
	llo su=0;
	llo cur=1;
	for(llo i=1;i<n;i++){
		su+=(it[i].a-it[i].b)*cur;
		cur*=2;
	}
	su+=(it[0].a-it[0].b);
	cur*=2;
	cur-=1;
	if(su<0){
		cout<<"NO"<<endl;
	}
	else{
		if(su%cur>0){
			cout<<"NO"<<endl;
		}
		else{
			llo ac=su/cur;
			for(llo i=1;i<n;i++){
				llo cc=it[i].a-it[i].b+ac;
				if(cc<0){
					cout<<"NO"<<endl;
					return 0;
				}
				if(cc%2>0){
					cout<<"NO"<<endl;
					return 0;
				}
				ac=cc/2;
			}
			cout<<"YES"<<endl;
		}
	}







	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -