89562024-02-07 22:42:06kukkermanMekk Mester munkái (50 pont)cpp17Accepted 50/5043ms6744 KiB
#include <iostream>
#include <vector>
#include <algorithm>

struct Megrendeles {
    int kezd;
    int veg;
    int azon;
};

std::vector<Megrendeles> beolvas(std::istream &be) {
    int n, h;
    be >> n >> h;

    std::vector<Megrendeles> m(n);
    for (int i = 0; i < n; i++) {
        m[i].azon = i + 1;
        be >> m[i].kezd >> m[i].veg;
    }

    return m;
}

void feldolgoz(std::vector<Megrendeles> &megrendelesek) {
    const auto n = megrendelesek.size();

    std::sort(megrendelesek.begin(), megrendelesek.end(), [](const Megrendeles &m1, const Megrendeles &m2) {
        return m1.veg < m2.veg;
    });

    std::vector<int> mester_munkai, fiu_munkai;
    int mester_szabad = 0, fiu_szabad = 0;
    for (const auto &m: megrendelesek) {
        if (mester_szabad <= m.kezd && (m.kezd < fiu_szabad || fiu_szabad < mester_szabad)) {
            mester_munkai.push_back(m.azon);
            mester_szabad = m.veg + 1;

        } else if (fiu_szabad <= m.kezd) {
            fiu_munkai.push_back(m.azon);
            fiu_szabad = m.veg + 1;
        }
    }

    using std::cout;

    cout << mester_munkai.size() << ' ' << fiu_munkai.size() << '\n';

    for (auto m: mester_munkai) {
        cout << m << ' ';
    }
    cout << '\n';

    for (auto m: fiu_munkai) {
        cout << m << ' ';
    }
    cout << '\n';
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    auto megrendelesek = beolvas(std::cin);
    feldolgoz(megrendelesek);

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1828 KiB
2Accepted0/06ms2272 KiB
3Accepted1/13ms2232 KiB
4Accepted1/13ms2340 KiB
5Accepted2/23ms2544 KiB
6Accepted2/23ms2908 KiB
7Accepted2/23ms2856 KiB
8Accepted2/23ms2984 KiB
9Accepted3/33ms3068 KiB
10Accepted1/13ms3088 KiB
11Accepted1/13ms3148 KiB
12Accepted2/23ms3156 KiB
13Accepted2/23ms3152 KiB
14Accepted2/23ms3236 KiB
15Accepted2/23ms3164 KiB
16Accepted3/33ms3160 KiB
17Accepted2/237ms5640 KiB
18Accepted2/235ms5684 KiB
19Accepted4/437ms5600 KiB
20Accepted4/437ms5592 KiB
21Accepted4/437ms5720 KiB
22Accepted4/439ms6208 KiB
23Accepted4/443ms6744 KiB