83272024-01-14 18:15:45zsomborTanúk (45 pont)cpp17Elfogadva 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 << " ";
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base45/45
1Elfogadva0/03ms3164 KiB
2Elfogadva0/046ms4668 KiB
3Elfogadva2/237ms3696 KiB
4Elfogadva2/23ms3780 KiB
5Elfogadva2/24ms4116 KiB
6Elfogadva2/23ms4076 KiB
7Elfogadva2/24ms4328 KiB
8Elfogadva2/24ms4544 KiB
9Elfogadva2/24ms4504 KiB
10Elfogadva2/24ms4508 KiB
11Elfogadva2/24ms4944 KiB
12Elfogadva2/27ms4996 KiB
13Elfogadva2/28ms4996 KiB
14Elfogadva2/29ms5036 KiB
15Elfogadva2/213ms5560 KiB
16Elfogadva2/213ms5588 KiB
17Elfogadva2/268ms7580 KiB
18Elfogadva2/2112ms8864 KiB
19Elfogadva2/2116ms9076 KiB
20Elfogadva2/2118ms9008 KiB
21Elfogadva2/2112ms8880 KiB
22Elfogadva2/2123ms9312 KiB
23Elfogadva2/2123ms9524 KiB
24Elfogadva3/3133ms9996 KiB