Submission #3669

# Submission time Handle Problem Language Result Execution time Memory
3669 2013-08-31T07:28:58 Z qja0950 King of penalty (kriii1_K) C++
1 / 1
24 ms 1476 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int p, n;
long long int ans;
int times[100001];
int main() {
	scanf("%d %d", &p, &n);
	p--;
	int i;
	for(i=1; i<=n; i++) scanf("%d", &times[i]);
	sort(times+1, times+n+1);
	for(i=1; i<=n; i++) {
		if(p-times[i]>=0) {
			ans+=p;
			p-=times[i];
		}else break;
	}
	printf("%d %lld", i-1, ans);
	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 12 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 12 ms 1476 KB Output is correct