Submission #151397

# Submission time Handle Problem Language Result Execution time Memory
151397 2019-09-02T15:52:35 Z gs14004 Coins (BOI06_coins) C++17
100 / 100
118 ms 4344 KB
#include <bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
typedef long long lint;
typedef pair<int, int> pi;

int main(){
	int n, k; scanf("%d %d",&n,&k);
	vector<pi> v(n + 1);
	for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
	v[n].first = k;
	int sum = 0, cnt = 0;
	for(int i=0; i<n; i++){
		if(!v[i].second && sum + v[i].first < v[i+1].first){
			sum += v[i].first;
			cnt++;
		}
	}
	if(sum == 0) sum = 1;
	cout << cnt << endl << k - sum << endl;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:8:17: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int n, k; scanf("%d %d",&n,&k);
            ~~~~~^~~~~~~~~~~~~~~
coins.cpp:10:30: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 256 KB Output is correct
2 Correct 2 ms 256 KB Output is correct
3 Correct 2 ms 376 KB Output is correct
4 Correct 2 ms 256 KB Output is correct
5 Correct 2 ms 256 KB Output is correct
6 Correct 2 ms 256 KB Output is correct
7 Correct 105 ms 4344 KB Output is correct
8 Correct 106 ms 4316 KB Output is correct
9 Correct 118 ms 4216 KB Output is correct
10 Correct 118 ms 4284 KB Output is correct