# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
3403 | wookayin | King of penalty (kriii1_K) | C++98 | 72 ms | 2060 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |