83272024-01-14 18:15:45zsomborTanúk (45 pont)cpp17Accepted 45/45133ms9996 KiB
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int n, h, k, done = 0, nxt = 0, mxi = 0;
vector <int> t;
vector <int> l(1e5 + 1, 0);
vector <int> r(1e5 + 1, 0);
vector <pair <int, int>> s1;
vector <pair <int, int>> s2;
vector <int> ans;

int main()
{
    cin >> n >> h >> k;
    t.resize(k);
    for (int& i : t) cin >> i;
    sort(t.begin(), t.end());
    t.push_back(1e9);
    for (int i = 1; i <= n; i++) {
        cin >> l[i] >> r[i];
        int lb = lower_bound(t.begin(), t.end(), l[i]) - t.begin();
        if (t[lb] > r[i]) continue;
        s1.push_back({ r[i],i });
        s2.push_back({ l[i], i });
    }
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    for (auto p : s1) {
        int i = p.second;
        if (done >= l[i]) continue;
        while (nxt < s2.size()) {
            int j = s2[nxt].second;
            if (l[j] > r[i]) break;
            if (r[j] > r[mxi]) mxi = j;
            nxt++;
        }
        done = r[mxi];
        ans.push_back(mxi);
    }
    cout << ans.size() << "\n";
    for (int i : ans) cout << i << " ";
}
SubtaskSumTestVerdictTimeMemory
base45/45
1Accepted0/03ms3164 KiB
2Accepted0/046ms4668 KiB
3Accepted2/237ms3696 KiB
4Accepted2/23ms3780 KiB
5Accepted2/24ms4116 KiB
6Accepted2/23ms4076 KiB
7Accepted2/24ms4328 KiB
8Accepted2/24ms4544 KiB
9Accepted2/24ms4504 KiB
10Accepted2/24ms4508 KiB
11Accepted2/24ms4944 KiB
12Accepted2/27ms4996 KiB
13Accepted2/28ms4996 KiB
14Accepted2/29ms5036 KiB
15Accepted2/213ms5560 KiB
16Accepted2/213ms5588 KiB
17Accepted2/268ms7580 KiB
18Accepted2/2112ms8864 KiB
19Accepted2/2116ms9076 KiB
20Accepted2/2118ms9008 KiB
21Accepted2/2112ms8880 KiB
22Accepted2/2123ms9312 KiB
23Accepted2/2123ms9524 KiB
24Accepted3/3133ms9996 KiB