Submission #3405

# Submission time Handle Problem Language Result Execution time Memory
3405 2013-08-31T05:32:49 Z pichulia King of penalty (kriii1_K) C++
1 / 1
24 ms 1476 KB
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<algorithm>

using namespace::std;

int a[100008];
int n, m;
void input()
{
	scanf("%d %d",&m,&n);
	for(int i=0; i<n; i++)
		scanf("%d",&a[i]);
	sort(a,a+n);
}

void process()
{
	int i, j;
	j=0;
	long long int k=0, l=0;
	for(i=0; i<n; i++)
	{
		j+=a[i];
		if(j>=m)
		{
			break;
		}
	}
	printf("%d ",i);
	for(j=0; j<i;j++)
	{
		k += (m-1-l);
		l += a[j];
	}
	printf("%lld",k);
}

void output()
{
}

int main()
{
	input();
	process();
	output();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1476 KB Output is correct
2 Correct 0 ms 1476 KB Output is correct
3 Correct 0 ms 1476 KB Output is correct
4 Correct 4 ms 1476 KB Output is correct
5 Correct 0 ms 1476 KB Output is correct
6 Correct 4 ms 1476 KB Output is correct
7 Correct 8 ms 1476 KB Output is correct
8 Correct 8 ms 1476 KB Output is correct
9 Correct 24 ms 1476 KB Output is correct
10 Correct 24 ms 1476 KB Output is correct
11 Correct 12 ms 1476 KB Output is correct
12 Correct 8 ms 1476 KB Output is correct
13 Correct 0 ms 1476 KB Output is correct
14 Correct 0 ms 1476 KB Output is correct
15 Correct 8 ms 1476 KB Output is correct