83032024-01-14 12:52:53anonTanúk (45 pont)cpp17Wrong answer 8/4582ms20932 KiB
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define FastIO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long long ll;
int main() {
    FastIO;
    bool flag;
    ll i, j, mh, N, H, K;
    cin >> N >> H >> K;
    vector<ll> tss(K);
    vector<array<ll, 2>> guests(N);
    for(i = 0; i < K; i++)
        cin >> tss[i];
    for(i = 0; i < N; i++)
        cin >> guests[i][0] >> guests[i][1];
    sort(all(tss));
    vector<array<vector<ll>, 2>> eps(H + 1);
    for(i = 0; i < N; i++) {
        for(j = 0; j < 2; j++)
            eps[guests[i][j]][j].push_back(i);
    }
    unordered_set<ll> here;
    unordered_set<ll> lc;
    vector<ll> ans;
    j = 0;
    for(i = 1; i <= H; i++) {
        for(const auto &x : eps[i][0])
            here.insert(x);
        if(i == tss[j]) {
            lc = here;
            j++;
        }
        flag = !lc.empty();
        if(flag) {
            flag = false;
            for(const auto &x : eps[i][1]) {
                if(lc.find(x) != lc.end()) {
                    flag = true;
                    break;
                }
            }
        }
        if(flag) {
            mh = *(here.begin());
            for(const auto &x : here) {
                if(guests[mh][1] < guests[x][1])
                    mh = x;
            }
            ans.push_back(mh);
            j = upper_bound(all(tss), guests[mh][1]) - tss.begin();
            lc.clear();
        }
        for(const auto &x : eps[i][1])
            here.erase(x);
    }
    cout << ans.size() << '\n';
    for(const auto &x : ans)
        cout << x + 1 << ' ';
    cout << '\n';
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base8/45
1Accepted0/03ms1832 KiB
2Accepted0/035ms12616 KiB
3Accepted2/232ms12704 KiB
4Accepted2/23ms3220 KiB
5Wrong answer0/23ms2872 KiB
6Partially correct1/23ms3476 KiB
7Wrong answer0/23ms3704 KiB
8Wrong answer0/23ms3656 KiB
9Wrong answer0/24ms7688 KiB
10Partially correct1/24ms5056 KiB
11Wrong answer0/27ms8284 KiB
12Wrong answer0/27ms8484 KiB
13Wrong answer0/28ms8584 KiB
14Wrong answer0/28ms6064 KiB
15Wrong answer0/29ms6728 KiB
16Wrong answer0/210ms10036 KiB
17Wrong answer0/243ms15308 KiB
18Wrong answer0/268ms18012 KiB
19Wrong answer0/264ms15536 KiB
20Accepted2/265ms16056 KiB
21Wrong answer0/267ms19232 KiB
22Wrong answer0/274ms19588 KiB
23Wrong answer0/271ms19620 KiB
24Wrong answer0/382ms20932 KiB