# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
3424 | joinsung | King of penalty (kriii1_K) | C++98 | 68 ms | 3212 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 <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
long long p, n;
cin >> p >> n;
vector<long long> time;
for (long long ni=0;ni<n;ni++) {
long long t;
cin >> t;
time.push_back(t);
}
sort(time.begin(), time.end());
long long penalty = 0;
long long t = p-1;
long long count = 0;
for (long long ni=0;ni<n;ni++) {
t -= time[ni];
if (t < 0)
break;
penalty += t + time[ni];
count++;
}
cout << count << " " << penalty << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |