124362024-12-17 19:44:50szabelrMekk Mester munkái (50 pont)cpp17Wrong answer 7/5094ms2872 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 s1[100001] = { 0 };
int s2[100001] = { 0 };
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;


    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 = 1;
        for (int j = t[i].kn; j <= t[i].vn; j++) {
            if (s1[j] == 1) {
                lehet1 = 0;
                break;
            }
        }
        if (lehet1) {
            for (int j = t[i].kn; j <= t[i].vn; j++) {
                s1[j] = 1;
            }
            jok1++;
            jokt1[a++] = t[i].sz;
        }
        else {
            int lehet2 = 1;
            for (int j = t[i].kn; j <= t[i].vn; j++) {
                if (s2[j] == 1) {
                    lehet2 = 0;
                    break;
                }
            }
            if (lehet2) {
                for (int j = t[i].kn; j <= t[i].vn; j++) {
                    s2[j] = 1;
                }
                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
base7/50
1Accepted0/01ms320 KiB
2Wrong answer0/08ms568 KiB
3Accepted1/12ms748 KiB
4Accepted1/12ms824 KiB
5Wrong answer0/22ms824 KiB
6Wrong answer0/22ms824 KiB
7Accepted2/22ms828 KiB
8Wrong answer0/22ms1080 KiB
9Accepted3/31ms500 KiB
10Wrong answer0/13ms824 KiB
11Wrong answer0/13ms824 KiB
12Wrong answer0/23ms1080 KiB
13Wrong answer0/23ms1080 KiB
14Wrong answer0/23ms1188 KiB
15Wrong answer0/23ms1080 KiB
16Wrong answer0/32ms412 KiB
17Wrong answer0/294ms2288 KiB
18Wrong answer0/294ms2296 KiB
19Wrong answer0/492ms2148 KiB
20Wrong answer0/487ms2364 KiB
21Wrong answer0/487ms2608 KiB
22Wrong answer0/489ms2360 KiB
23Wrong answer0/493ms2872 KiB