114862024-10-08 07:47:13szabelrMekk Mester munkái (50 pont)cpp14Wrong answer 7/5093ms3472 KiB
#include <iostream>
#include <algorithm>
using namespace std;

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

int h(munka x, munka y) {
    return x.vn < y.vn;  // cleaner comparison
}

int main() {
    int n, H;
    cin >> n >> H;
    
    int s1[H + 1] = {0}; // Availability array 1
    int s2[H + 1] = {0}; // Availability array 2
    int jok1 = 0, jok2 = 0;
    
    int jokt1[n] = {0};  // Jobs for schedule 1
    int jokt2[n] = {0};  // Jobs for schedule 2
    
    int a = 0, b = 0;    // Track index for jokt1, jokt2
    munka t[n];
    
    for (int i = 0; i < n; i++) {
        cin >> t[i].kn >> t[i].vn;
        t[i].sz = i + 1; // job index
    }

    sort(t, t + n, h);  // Sorting by vn

    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/03ms420 KiB
2Wrong answer0/09ms616 KiB
3Accepted1/14ms1164 KiB
4Accepted1/13ms1168 KiB
5Wrong answer0/24ms1168 KiB
6Wrong answer0/24ms1128 KiB
7Accepted2/24ms1268 KiB
8Wrong answer0/23ms1272 KiB
9Accepted3/33ms360 KiB
10Wrong answer0/14ms1128 KiB
11Wrong answer0/14ms1256 KiB
12Wrong answer0/24ms1180 KiB
13Wrong answer0/24ms1272 KiB
14Wrong answer0/24ms1128 KiB
15Wrong answer0/24ms1264 KiB
16Wrong answer0/33ms652 KiB
17Wrong answer0/293ms3112 KiB
18Wrong answer0/293ms3088 KiB
19Wrong answer0/489ms3096 KiB
20Wrong answer0/485ms3048 KiB
21Wrong answer0/485ms3220 KiB
22Wrong answer0/485ms3176 KiB
23Wrong answer0/490ms3472 KiB