| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 164411 | tselmegkh | 학교 설립 (IZhO13_school) | C++14 | 616 ms | 16448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
int sum[N][2];
int main(){
int n, m, s;
cin >> n >> m >> s;
vector<pair<int, int>> v1, v2;
for(int i = 0; i < n; i++){
int a, b;
cin >> a >> b;
v1.push_back({a - b, a});
v2.push_back({b - a, b});
}
sort(v1.rbegin(), v1.rend());
sort(v2.rbegin(), v2.rend());
int tot = 0;
multiset<int> ms;
for(int i = 0; i < n; i++){
ms.insert(v1[i].second);
tot += v1[i].second;
if(ms.size() > m){
tot -= *ms.begin();
ms.erase(ms.begin());
}
sum[i + 1][0] = tot;
}
tot = 0;
ms.clear();
for(int i = 0; i < n; i++){
ms.insert(v2[i].second);
tot += v2[i].second;
if(ms.size() > s){
tot -= *ms.begin();
ms.erase(ms.begin());
}
sum[i + 1][1] = tot;
}
int ans = 0;
for(int i = m; i <= n - s; i++){
ans = max(ans, sum[i][0] + sum[n - i - 1][1]);
}
cout << ans << '\n';
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
