82992024-01-14 12:11:23zsomborTanúk (45 pont)cpp17Wrong answer 34/45134ms9672 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]) 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 < n) {
            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
base34/45
1Accepted0/04ms3164 KiB
2Wrong answer0/048ms5168 KiB
3Accepted2/243ms4956 KiB
4Accepted2/23ms3764 KiB
5Accepted2/23ms4108 KiB
6Partially correct1/24ms4088 KiB
7Wrong answer0/24ms4176 KiB
8Partially correct1/24ms4324 KiB
9Accepted2/24ms4252 KiB
10Wrong answer0/24ms4320 KiB
11Wrong answer0/24ms4800 KiB
12Accepted2/27ms5064 KiB
13Accepted2/28ms5184 KiB
14Accepted2/29ms5224 KiB
15Accepted2/213ms5536 KiB
16Partially correct1/213ms5580 KiB
17Wrong answer0/268ms7312 KiB
18Accepted2/2111ms8788 KiB
19Accepted2/2115ms9000 KiB
20Accepted2/2119ms9120 KiB
21Accepted2/2112ms9096 KiB
22Accepted2/2122ms9304 KiB
23Accepted2/2122ms9512 KiB
24Accepted3/3134ms9672 KiB