124382024-12-17 20:06:12szabelrMekk Mester munkái (50 pont)cpp17Accepted 50/5089ms2160 KiB
#include <iostream>
#include <algorithm>
using namespace std;

struct munka {
    int kn, vn, sz;
};

int h(munka x, munka y) {
    if (x.vn < y.vn)
        return true;
    else if (x.vn > y.vn)
        return false;
    else
        return x.kn > y.kn;
}

int jok1 = 0, jok2 = 0;

int jokt1[100001] = { 0 };
int jokt2[100001] = { 0 };

int a = 0, b = 0;
munka t[100001];

int main() {
    int n, H;
    cin >> n >> H;
    int veg1=0, veg2=0;
    for (int i = 0; i < n; i++) {
        cin >> t[i].kn >> t[i].vn;
        t[i].sz = i + 1; 
    }

    sort(t, t + n, h); 

    for (int i = 0; i < n; i++) {
        int lehet1 = t[i].kn > veg1;
        int lehet2 = t[i].kn > veg2;
        if (lehet1 and lehet2 == 0) {
            veg1 = t[i].vn;
            jok1++;
            jokt1[a++] = t[i].sz;
        }
        else if (lehet2 and lehet1 == 0) {
            veg2 = t[i].vn;
            jok2++;
            jokt2[b++] = t[i].sz;
        }
        else if (lehet1 and lehet2) {
            if (veg1 > veg2) {
                veg1 = t[i].vn;
                jok1++;
                jokt1[a++] = t[i].sz;
            }
            else {
                veg2 = t[i].vn;
                jok2++;
                jokt2[b++] = t[i].sz;
            }
        }
    }
    cout << jok1 << " " << jok2 << endl;

    for (int i = 0; i < jok1; i++) {
        cout << jokt1[i] << " ";
    }
    cout << endl;

    for (int i = 0; i < jok2; i++) {
        cout << jokt2[i] << " ";
    }
    cout << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms320 KiB
2Accepted0/08ms320 KiB
3Accepted1/11ms320 KiB
4Accepted1/11ms320 KiB
5Accepted2/21ms412 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms352 KiB
8Accepted2/21ms320 KiB
9Accepted3/31ms320 KiB
10Accepted1/11ms320 KiB
11Accepted1/12ms420 KiB
12Accepted2/22ms500 KiB
13Accepted2/22ms508 KiB
14Accepted2/22ms420 KiB
15Accepted2/22ms508 KiB
16Accepted3/31ms320 KiB
17Accepted2/285ms1340 KiB
18Accepted2/281ms1556 KiB
19Accepted4/481ms1372 KiB
20Accepted4/481ms1548 KiB
21Accepted4/483ms1592 KiB
22Accepted4/482ms1592 KiB
23Accepted4/489ms2160 KiB