228122026-01-15 19:28:06AblablablaTanúk (45 pont)cpp17Elfogadva 45/45131ms2984 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<int> ido(k);
    for(int &x : ido){
        cin >> x;
    }

    sort(ido.begin(), ido.end());


    vector<pii> alap(n);
    for(auto& x : alap){
        cin >> x.first >> x.second;
    }

    vector<pii> kezd, veg;

    for(int i = 0; i < n; i++){
        int elso = lower_bound(ido.begin(), ido.end(), alap[i].first) - ido.begin();

        if(elso != k && ido[elso] <= alap[i].second){
            kezd.push_back({alap[i].first, i});
            veg.push_back({alap[i].second, i});
        }
    }

    sort(kezd.begin(), kezd.end());
    sort(veg.begin(), veg.end());

    int kesz = 0;
    int tart = 0;
    n = kezd.size();

    vector<int> ans;

    for(int i = 0; i < n; i++){
        int ind = veg[i].second;

        if(kesz >= alap[ind].first) continue;

        int kovi = 0, ert = 0;

        while(tart < n){
            int a = kezd[tart].second;

            if(alap[ind].second < alap[a].first){
                break;
            }

            if(alap[a].second > ert){
                ert = alap[a].second;
                kovi = a;
            }

            tart++;
        }

        ans.push_back(kovi);
        kesz = ert;
    }

    cout << ans.size() << "\n";
    for(int x : ans){
        cout << x + 1 << " ";
    }
    cout << "\n";
}
RészfeladatÖsszpontTesztVerdiktIdőMemória
base45/45
1Elfogadva0/01ms316 KiB
2Elfogadva0/043ms1368 KiB
3Elfogadva2/235ms564 KiB
4Elfogadva2/21ms316 KiB
5Elfogadva2/21ms316 KiB
6Elfogadva2/21ms404 KiB
7Elfogadva2/21ms316 KiB
8Elfogadva2/22ms316 KiB
9Elfogadva2/22ms324 KiB
10Elfogadva2/21ms316 KiB
11Elfogadva2/23ms316 KiB
12Elfogadva2/24ms316 KiB
13Elfogadva2/26ms440 KiB
14Elfogadva2/28ms632 KiB
15Elfogadva2/210ms740 KiB
16Elfogadva2/29ms680 KiB
17Elfogadva2/267ms1804 KiB
18Elfogadva2/2112ms2852 KiB
19Elfogadva2/2115ms2928 KiB
20Elfogadva2/2115ms2924 KiB
21Elfogadva2/2111ms2984 KiB
22Elfogadva2/2123ms2984 KiB
23Elfogadva2/2120ms2984 KiB
24Elfogadva3/3131ms2900 KiB