| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 | 
|---|---|---|---|---|---|---|---|
| 49681 | mra2322001 | Schools (IZhO13_school) | C++14 | 131 ms | 25632 KiB | 
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define f0(i, n) for(int i(0); i<(n); i++)
#define f1(i, n) for(int i(1); i<=(n); i++)
using namespace std;
typedef long long ll;
typedef pair <int, int> pii;
const int N = 300002;
int n, s, t;
long t1[N], t2[N];
pii a[N];
istream& operator >> (istream &is, pii &iu){
    cin >> iu.first >> iu.second;
}
int main(){
    ios_base::sync_with_stdio(0);
  
    cin >> n >> s >> t;
    f1(i, n) cin >> a[i];
    sort(a + 1, a + n + 1, [&](pii a1, pii a2){
         return (a1.second - a1.first) < (a2.second - a2.first);
    });
    priority_queue <int, vector <int>, greater <int> > q;
    f1(i, n){
        if(q.size() < s){
            t1[i] = t1[i - 1] + a[i].first;
            q.push(a[i].first);
        }
        else if(q.top() < a[i].first){
            t1[i] = t1[i - 1] - q.top() + a[i].first;
            q.pop();
            q.push(a[i].first);
        }
        else{
            t1[i] = t1[i - 1];
        }
    }
    while(q.size()) q.pop();
    for(int i = n; i >= 1; i--){
        if(q.size() < t){
            t2[i] = t2[i + 1] + a[i].second;
            q.push(a[i].second);
        }
        else if(q.top() < a[i].second){
            t2[i] = t2[i + 1] - q.top() + a[i].second;
            q.pop();
            q.push(a[i].second);
        }
        else{
            t2[i] = t2[i + 1];
        }
    }
    long res = 0;
    f1(i, n){
        if(i >= s && (n - i) >= t) res = max(res, t1[i] + t2[i + 1]);
    }
    cout << res;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
