Submission #4178

# Submission time Handle Problem Language Result Execution time Memory
4178 2013-09-03T06:10:32 Z hsswill King of penalty (kriii1_K) C++
0 / 1
0 ms 1476 KB
#include<stdio.h>
#include<algorithm>

using std::sort;

int data[100001];

int main(void)
{
	int a, i, sum, n, t = 0, result;
	
	scanf("%d %d",&a,&n);

	for(i = 0; i < n; i++)
		scanf("%d",&data[i]);

	sort( data, data+n );
	sum = 0;

	for(i = 0; i < n; i++) 
	{
		sum += data[i];
		if( t+sum > a ) break; 
		t += sum; 
	}
	result = i; 
	sum = t = 0;
	for(i = result-1; i >= 0; i--) 
	{
		sum += data[i];
		t += sum;
	}
	printf("%d %d",result,t+a);
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 1476 KB Output isn't correct
2 Halted 0 ms 0 KB -