Submission #3506

# Submission time Handle Problem Language Result Execution time Memory
3506 2013-08-31T06:13:40 Z imsifile King of penalty (kriii1_K) C++
1 / 1
24 ms 1956 KB
#include<stdio.h>
#include<algorithm>
using namespace std;

long long p, n, ba[111111], cnt, hh, dap, i;

int main(){
	scanf("%lld%lld", &p,&n);
	for(i=0; i<n; i++)scanf("%lld", &ba[i]);
	sort(ba, ba+n);
	for(i=0; i<n; i++){
		if(hh+ba[i]>=p)break;
		cnt++, hh+=ba[i];
	}
	hh=p-1;
	for(i=0; i<cnt; i++)dap+=hh, hh-=ba[i];
	printf("%lld %lld", cnt, dap);
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1956 KB Output is correct
2 Correct 0 ms 1956 KB Output is correct
3 Correct 0 ms 1956 KB Output is correct
4 Correct 4 ms 1956 KB Output is correct
5 Correct 0 ms 1956 KB Output is correct
6 Correct 4 ms 1956 KB Output is correct
7 Correct 8 ms 1956 KB Output is correct
8 Correct 8 ms 1956 KB Output is correct
9 Correct 24 ms 1956 KB Output is correct
10 Correct 20 ms 1956 KB Output is correct
11 Correct 16 ms 1956 KB Output is correct
12 Correct 4 ms 1956 KB Output is correct
13 Correct 0 ms 1956 KB Output is correct
14 Correct 0 ms 1956 KB Output is correct
15 Correct 12 ms 1956 KB Output is correct