Submission #137905

# Submission time Handle Problem Language Result Execution time Memory
137905 2019-07-28T13:45:19 Z onjo0127 Coins (BOI06_coins) C++11
100 / 100
134 ms 12024 KB
#include <bits/stdc++.h>
using namespace std;

const int L = 500000000;
int N, K, A[500009];
long long C[500009];

int main() {
	scanf("%d%d",&N,&K);
	for(int i=1; i<=N; i++) {
		scanf("%lld%d",&C[i],&A[i]);
		A[i] = 1 - A[i];
	} C[N+1] = K;
	long long s = 0;
	int ans = 0, la = K-1;
	for(int i=1; i<=N; i++) {
		if(A[i] && C[i] + s < C[i+1]) {
			++ans;
			la = K - (C[i] + s);
			s += C[i];
		}
	}
	printf("%d\n%d", ans, la);
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:9:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&N,&K);
  ~~~~~^~~~~~~~~~~~~~
coins.cpp:11:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%lld%d",&C[i],&A[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 380 KB Output is correct
2 Correct 2 ms 376 KB Output is correct
3 Correct 2 ms 376 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 252 KB Output is correct
7 Correct 107 ms 11896 KB Output is correct
8 Correct 107 ms 11868 KB Output is correct
9 Correct 122 ms 12024 KB Output is correct
10 Correct 134 ms 11768 KB Output is correct