Submission #199456

# Submission time Handle Problem Language Result Execution time Memory
199456 2020-02-01T12:54:33 Z TadijaSebez Coins (BOI06_coins) C++11
100 / 100
174 ms 10104 KB
#include <bits/stdc++.h>
using namespace std;
const int N=500050;
int c[N],d[N];
int main()
{
	int n,k;
	scanf("%i %i",&n,&k);
	int sum=0,cnt=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%i %i",&c[i],&d[i]);
	}
	c[n+1]=k;
	for(int i=1;i<=n;i++)
	{
		if(d[i]==0)
		{
			if(c[i]+sum<c[i+1])
			{
				sum+=c[i];
				cnt++;
			}
		}
	}
	if(cnt==0) sum=1;
	printf("%i\n%i\n",cnt,k-sum);
	return 0;
}

Compilation message

coins.cpp: In function 'int main()':
coins.cpp:8:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i %i",&n,&k);
  ~~~~~^~~~~~~~~~~~~~~
coins.cpp:12:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%i %i",&c[i],&d[i]);
   ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 130 ms 10104 KB Output is correct
8 Correct 127 ms 9980 KB Output is correct
9 Correct 174 ms 9976 KB Output is correct
10 Correct 141 ms 9848 KB Output is correct