# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3568 | waps12b | King of penalty (kriii1_K) | C++98 | 24 ms | 1868 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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\n", &val[i]);
sort(val, val+N);
ll cur = P-1, ans = 0, ans_n = 0;
for(int i = 0 ; ; 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 |
---|---|---|---|---|
Fetching results... |