# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
100281 | choikiwon | 학교 설립 (IZhO13_school) | C++17 | 185 ms | 7664 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MN = 300010;
int N, M, S;
pii P[MN];
priority_queue<int> pq;
ll dp[MN], cost;
int main() {
scanf("%d %d %d", &N, &M, &S);
for(int i = 0; i < N; i++) {
scanf("%d %d", &P[i].first, &P[i].second);
}
sort(P, P + N);
reverse(P, P + N);
for(int i = 0; i < M; i++) {
pq.push(P[i].second - P[i].first);
cost += P[i].first;
}
dp[M - 1] = cost;
for(int i = M; i < M + S; i++) {
pq.push(P[i].second - P[i].first);
cost += P[i].first;
cost += pq.top(); pq.pop();
dp[i] = cost;
}
ll ans = dp[M + S - 1];
while(!pq.empty()) pq.pop();
for(int i = M + S; i < N; i++) pq.push(P[i].second);
cost = 0;
for(int i = M + S - 2; i >= M - 1; i--) {
pq.push(P[i + 1].second);
cost += pq.top(); pq.pop();
ans = max(ans, dp[i] + cost);
}
printf("%lld", ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |