Submission #4062

# Submission time Handle Problem Language Result Execution time Memory
4062 2013-08-31T16:24:20 Z shinhj88 King of penalty (kriii1_K) C++
0 / 1
0 ms 1236 KB
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
long long int P,N;
vector<long long int> data;
void input()
{
	scanf("%lld%lld",&P,&N);
	data.resize(N+1);
	for(int i=0;i<N;i++)
	{
		scanf("%lld",&data[i]);
	}
	sort(data.begin(),data.end());
	
}
void process()
{
	
	P--;
	long long int ans=0,sum=0;
	int i;
	for(i=0;i<=N;i++)
	{
		if(P-data[i]<0)break;		
		ans+=P;
		P-=data[i];
		
	}
	printf("%d %lld\n",i,ans);

	
}
int main()
{
	input();
	process();

}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1236 KB Output isn't correct
2 Halted 0 ms 0 KB -