# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
683001 | smartmonky | Schools (IZhO13_school) | C++14 | 182 ms | 15004 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define int long long
using namespace std;
const int N = (int)3e5+7;
int p[N], p2[N];
bool comp(pair <int,int> a, pair <int,int> b){
return a.ff - a.ss > b.ff - b.ss;
}
main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
int n, m, s;
cin >> n >> m >> s;
vector <pair <int,int> > vp(n);
for(int i = 0; i < n; i++){
cin >> vp[i].ff >> vp[i].ss;
}
sort(all(vp), comp);
multiset <int> st;
int sum = 0;
for(int i = 0; i < n; i++){
sum += vp[i].ff;
st.insert(vp[i].ff);
if(st.size() > m){
sum -= *(st.begin());
st.erase(st.begin());
}
p[i] = sum;
}
st.clear();
sum = 0;
for(int i = n - 1; i >= 1; i--){
sum += vp[i].ss;
st.insert(vp[i].ss);
if(st.size() > s){
sum -= *(st.begin());
st.erase(st.begin());
}
p2[i] = sum;
}
int ans = 0;
for(int i = m - 1; i < n - s; i++){
ans = max(ans, p[i] + p2[i + 1]);
}
cout << ans;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |