Submission #136094

# Submission time Handle Problem Language Result Execution time Memory
136094 2019-07-24T17:34:23 Z dnass Remittance (JOI19_remittance) C++14
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long int lld;

lld n;
lld a[21], give[21];

int main(){
	scanf("%lld", &n);
	for(lld i=0;i<n;i++){
		lld tmpa, tmpb; scanf("%lld %lld", &tmpa, &tmpb);
		a[i] = tmpa-tmpb;
	}
	lld sum = 0;
	lld pow_two = 1;
	for(lld i=0;i<n;i++){
		sum += pow_two*a[i];
		pow_two *= 2;
	}
	if(sum%(pow_two-1)!=0){
		printf("No\n");
		return 0;
	}
	sum /= (pow_two-1);
	lld first_ind = -1;
	for(lld i=n-1;i>=0;i--){
		sum *= 2; sum -= a[i];
		if(sum<0){
			printf("No\n");
			return 0;
		}
		give[(i-1+n)%n] = sum;
		if(2*sum<=a[(i-1+n)%n]) first_ind = (i-1+n)%n;
	}
	if(first_ind==-1){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}

Compilation message

remittance.cpp: In function 'int main()':
remittance.cpp:10:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%lld", &n);
  ~~~~~^~~~~~~~~~~~
remittance.cpp:12:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   lld tmpa, tmpb; scanf("%lld %lld", &tmpa, &tmpb);
                   ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 256 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 2 ms 376 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Incorrect 2 ms 256 KB Output isn't correct
9 Halted 0 ms 0 KB -