Submission #3668

# Submission time Handle Problem Language Result Execution time Memory
3668 2013-08-31T07:27:57 Z qja0950 King of penalty (kriii1_K) C++
0 / 1
16 ms 1476 KB
#include <stdio.h>
#include <algorithm>
using namespace std;
int p, n, 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 %d", 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 4 ms 1476 KB Output is correct
8 Correct 8 ms 1476 KB Output is correct
9 Incorrect 16 ms 1476 KB Output isn't correct
10 Halted 0 ms 0 KB -