답안 #1096969

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1096969 2024-10-05T15:17:33 Z codexistent 학교 설립 (IZhO13_school) C++14
10 / 100
131 ms 11716 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 300005
#define FOR(i, a, b) for(ll i = a; i <= b; i++)

ll n, t[2], pfx[MAXN], r = 0;
vector<array<ll, 2>> v(MAXN);

int main(){
    cin >> n >> t[0] >> t[1];
    FOR(i, 1, n) cin >> v[i][0] >> v[i][1];

    sort(begin(v) + 1, begin(v) + 1 + n, [&](const auto &a, const auto &b) {
        return a[0] - a[1] > b[0] - b[1];
    });

    priority_queue<ll> pq;
    pfx[0] = 0;
    FOR(i, 1, n){
        pfx[i] = pfx[i - 1];
        pfx[i] += v[i][0], pq.push(-v[i][0]);
        while((ll)pq.size() > t[0]) pfx[i] += pq.top(), pq.pop();
    }

    priority_queue<ll>().swap(pq);
    ll sfx = 0;
    for(ll i = n + 1; i >= 1; i--){
        if(i >= n){
            sfx += v[i][1];
            pq.push(-v[i][1]);
            while((ll)pq.size() > t[1]) sfx += pq.top(), pq.pop();
        }

        if((ll)pq.size() == t[1] && i - 1 >= t[1]) r = max(r, sfx + pfx[i - 1]);
    }

    cout << r << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB Output isn't correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Incorrect 2 ms 4956 KB Output isn't correct
5 Incorrect 2 ms 5148 KB Output isn't correct
6 Incorrect 2 ms 4956 KB Output isn't correct
7 Incorrect 3 ms 5204 KB Output isn't correct
8 Incorrect 4 ms 5212 KB Output isn't correct
9 Incorrect 4 ms 5212 KB Output isn't correct
10 Incorrect 3 ms 5212 KB Output isn't correct
11 Incorrect 4 ms 5212 KB Output isn't correct
12 Incorrect 4 ms 5212 KB Output isn't correct
13 Incorrect 18 ms 6140 KB Output isn't correct
14 Incorrect 34 ms 6744 KB Output isn't correct
15 Incorrect 64 ms 8064 KB Output isn't correct
16 Incorrect 76 ms 8656 KB Output isn't correct
17 Incorrect 103 ms 10116 KB Output isn't correct
18 Incorrect 103 ms 10492 KB Output isn't correct
19 Incorrect 110 ms 10952 KB Output isn't correct
20 Incorrect 131 ms 11716 KB Output isn't correct