# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1114543 | Tsagana | 학교 설립 (IZhO13_school) | C++14 | 98 ms | 6720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false);cin.tie();cout.tie();
#define all(x) x.begin(), x.end()
#define int long long
#define pq priority_queue
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pp pop_back
#define F first
#define S second
#define sp << ' ' <<
#define nl << '\n'
using namespace std;
bool cmp(pair<int, int> a, pair<int, int> b) {return (a.F - a.S < b.F - b.S ? 1 : 0);}
void solve () {
int n, m, s; cin >> n >> m >> s;
vector<pair<int, int>> v(n);
for (auto &i : v) cin >> i.F >> i.S;
sort(all(v), cmp);
int ans = 0;
int sum = 0;
pq<int> q;
for (int i = 0; i < n; i++) {
q.push(-v[i].S);
sum += v[i].S;
while (q.size() > s) {sum += q.top(); q.pop();}
v[i].S = sum;
}
sum = 0;
pq<int> ().swap(q);
for (int i = n-1; i >= 0; i--) {
q.push(-v[i].F);
sum += v[i].F;
while (q.size() > m) {sum += q.top(); q.pop();}
ans = max(ans, sum + (i ? v[i-1].S : 0));
}
cout << ans;
}
signed main() {IOS solve(); return 0;}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |