# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
4112 | jays | King of penalty (kriii1_K) | C++98 | 24 ms | 1980 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 <algorithm>
#include <cstdio>
#include <vector>
typedef long long ll;
using namespace std;
int P, N;
vector<int> pen;
ll solve(int n) {
ll ret = 0;
int cp = P - 1;
for (int i = 0; i < n; ++i) {
ret += cp;
cp -= pen[i];
}
return ret;
}
int main() {
scanf("%d%d", &P, &N);
for (int i = 0; i < N; ++i) {
int t; scanf("%d", &t);
pen.push_back(t);
}
sort(pen.begin(), pen.end());
int sum = 0;
for (int i = 0; i < pen.size(); ++i) {
sum += pen[i];
if (sum >= P) {
printf("%d %lld\n", i, solve(i));
return 0;
}
}
printf("%d %lld\n", N, solve(N));
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |