Submission #3574

# Submission time Handle Problem Language Result Execution time Memory
3574 2013-08-31T06:41:16 Z waps12b King of penalty (kriii1_K) C++
1 / 1
24 ms 1868 KB
#include<cstdio>
#include<algorithm>
using namespace std;
#define ll long long
ll val[100000];
int main() {
	ll P, N;
	scanf("%lld%lld", &P, &N);

	for(int i = 0 ; i < N ; i++) scanf("%lld", &val[i]);

	sort(val, val+N);
	ll cur = P-1, ans = 0, ans_n = 0;
	for(int i = 0 ; i < N ; i++) {
		if( cur >= val[i] ) {
			ans_n++;
			ans += cur;
			cur -= val[i];
		}
		else break;
	}
	printf("%lld %lld\n", ans_n, ans);
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 1868 KB Output is correct
2 Correct 0 ms 1868 KB Output is correct
3 Correct 0 ms 1868 KB Output is correct
4 Correct 4 ms 1868 KB Output is correct
5 Correct 0 ms 1868 KB Output is correct
6 Correct 4 ms 1868 KB Output is correct
7 Correct 8 ms 1868 KB Output is correct
8 Correct 8 ms 1868 KB Output is correct
9 Correct 20 ms 1868 KB Output is correct
10 Correct 24 ms 1868 KB Output is correct
11 Correct 16 ms 1868 KB Output is correct
12 Correct 12 ms 1868 KB Output is correct
13 Correct 0 ms 1868 KB Output is correct
14 Correct 0 ms 1868 KB Output is correct
15 Correct 12 ms 1868 KB Output is correct