# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3403 | wookayin | King of penalty (kriii1_K) | C++98 | 72 ms | 2060 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.
#pragma warning(disable:4996)
#include <algorithm>
#include <functional>
#include <cstdio>
#include <iostream>
#include <vector>
using namespace std;
long long P;
int n;
vector<int> a;
int main() {
cin >> P >> n;
a.resize(n);
for(int i=0; i<n; ++i) cin >> a[i];
sort(a.begin(), a.end(), greater<int>());
long long sum = 0;
long long ws = 0;
int problems = 0;
long long ans = 0;
int ansp = 0;
for(int i = n - 1; i >= 0; -- i) {
sum += a[i];
long long start_time = P-1-sum;
if(start_time < 0) continue;
problems ++;
long long penalty = problems * sum - ws + problems * start_time;
if(ans < penalty) {
ans = penalty;
ansp = problems;
}
ws += sum;
}
cout << ansp << ' ' << ans << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |