Submission #405905

# Submission time Handle Problem Language Result Execution time Memory
405905 2021-05-17T03:32:23 Z gs21045 Coins (BOI06_coins) C++14
100 / 100
130 ms 9960 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]
    8 |  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]
   10 |  for(int i=0; i<n; i++) scanf("%d %d",&v[i].first,&v[i].second);
      |                         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 130 ms 9960 KB Output is correct
8 Correct 106 ms 9924 KB Output is correct
9 Correct 114 ms 9952 KB Output is correct
10 Correct 111 ms 9684 KB Output is correct