82712024-01-14 07:58:37MagyarKendeSZLGMekk Mester munkái (50 pont)cpp17Accepted 50/5056ms8580 KiB
#include <bits/stdc++.h>
#define speed cin.tie(0); ios::sync_with_stdio(0)
using namespace std;

int main() {
    speed;

    int N, H;
    cin >> N >> H;

    priority_queue<array<int, 3>, vector<array<int, 3>>, greater<array<int, 3>>> pq;
    for (int i = 1; i <= N; i++) {
        int k, v;
        cin >> k >> v;
        pq.push({ v, k, i });
    }

    array<vector<array<int, 2>>, 2> workS;
    workS[0].push_back({ 0, 0 });
    workS[1].push_back({ 0, 0 });

    while (!pq.empty()) {
        auto [v, k, id] = pq.top(); pq.pop();
        int mn = 1e9, mni = -1;

        for (int i = 0; i < 2; i++) {
            int gap = k - workS[i].back()[0];
            if (0 < gap && gap < mn) {
                mn = gap;
                mni = i;
            }
        }

        if (mni != -1) {
            workS[mni].push_back({ v, id });
        }
    }

    cout << workS[0].size() - 1 << ' ' << workS[1].size() - 1 << '\n';

    for (int i = 0; i < 2; i++) {
        for (int j = 1; j < workS[i].size(); j++) {
            cout << workS[i][j][1] << ' ';
        }
        cout << '\n';
    }
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1824 KiB
2Accepted0/07ms2608 KiB
3Accepted1/13ms2300 KiB
4Accepted1/13ms2388 KiB
5Accepted2/23ms2688 KiB
6Accepted2/23ms2900 KiB
7Accepted2/23ms2780 KiB
8Accepted2/23ms2824 KiB
9Accepted3/33ms2896 KiB
10Accepted1/13ms3044 KiB
11Accepted1/13ms3012 KiB
12Accepted2/23ms3092 KiB
13Accepted2/23ms3076 KiB
14Accepted2/23ms3156 KiB
15Accepted2/23ms3408 KiB
16Accepted3/33ms3628 KiB
17Accepted2/248ms6776 KiB
18Accepted2/248ms6820 KiB
19Accepted4/448ms7000 KiB
20Accepted4/448ms7044 KiB
21Accepted4/448ms7056 KiB
22Accepted4/450ms6964 KiB
23Accepted4/456ms8580 KiB