217662026-01-13 20:22:12TaxiradioTanúk (45 pont)cpp17Accepted 45/45134ms3624 KiB
// Source: https://usaco.guide/general/io

#include <algorithm>
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

int32_t main() {
    int n , h , k;cin >> n >> h >> k;
    vector<int> a;
    for(int i = 0; i < k; i++){
        int x;cin >> x;
        a.push_back(x);
    }
    vector<array<int , 2>> o(h+1 , {-1 , -1});
    sort(a.begin() , a.end());
    vector<array<int , 2>> b;
    for(int i = 0; i < n; i++){
        int l , r; cin >> l >> r;
        if(lower_bound(a.begin() , a.end() , l) == upper_bound(a.begin() , a.end() , r))continue;
        b.push_back({r , l});
        array<int , 2> z = {r , i+1};
        o[l] = max(z , o[l]);
    }
    for(int i = 1; i <= h; i++){
        o[i] = max(o[i] , o[i-1]);
    }
    sort(b.begin() , b.end());
    int u = -1;
    vector<int> ans;
    for(int i = 0; i < b.size(); i++){
        if(u < b[i][1]){
            ans.push_back(o[b[i][0]][1]);
            u = o[b[i][0]][0];
        }
    }
    cout << ans.size() << endl;
    for(int x : ans)cout << x << " ";
}
SubtaskSumTestVerdictTimeMemory
base45/45
1Accepted0/01ms316 KiB
2Accepted0/041ms1708 KiB
3Accepted2/232ms1268 KiB
4Accepted2/21ms564 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms564 KiB
7Accepted2/22ms564 KiB
8Accepted2/22ms564 KiB
9Accepted2/23ms1116 KiB
10Accepted2/22ms564 KiB
11Accepted2/24ms1076 KiB
12Accepted2/26ms1116 KiB
13Accepted2/27ms1168 KiB
14Accepted2/28ms828 KiB
15Accepted2/212ms1076 KiB
16Accepted2/212ms1332 KiB
17Accepted2/268ms2452 KiB
18Accepted2/2109ms3196 KiB
19Accepted2/2115ms2948 KiB
20Accepted2/2115ms3000 KiB
21Accepted2/2109ms3240 KiB
22Accepted2/2123ms3624 KiB
23Accepted2/2122ms3368 KiB
24Accepted3/3134ms3624 KiB