83752024-01-15 10:57:11antiMekk Mester munkái (50 pont)cpp14Accepted 50/5087ms7516 KiB
#include <iostream>
#include <algorithm>

using namespace std;

struct munka{
    int k, v;
    int sorszam;
};

bool comp(munka m1, munka m2){
    return m1.v < m2.v;
}

int main()
{
    int n, h;
    cin >> n >> h;
    munka t[n];
    for(int i=0; i<n; i++){
        cin >> t[i].k >> t[i].v;
        t[i].sorszam = i+1;
    }
    sort(t, t+n, comp);

    int apa[n] = {-1}, fia[n] = {-1};
    int m1=0, m2=0, i=0;
    bool mekk = true;
    bool apanem = false, fianem = false;

    apa[m1] = i;
    m1++;
    i++;

    do{
        if(mekk){
            if(t[i].k > t[apa[m1-1]].v){
                apa[m1] = i;
                m1++;
                i++;
                apanem = false;
                fianem = false;
            }
            else{
                apanem = true;
                mekk = false;
            }
        }
        else{
            if(fia[0] == -1){
                fia[0] = i;
                m2++;
                i++;
                apanem = false;
                fianem = false;
            }
            else if(t[i].k > t[fia[m2-1]].v){
                fia[m2] = i;
                m2++;
                i++;
                apanem = false;
                fianem = false;
            }
            else{
                fianem = true;
                mekk = true;
            }
        }
        if(apanem && fianem){
            i++;
            apanem = false;
            fianem = false;
        }
    }while(i!=n);
    cout << m1 << " " << m2 << endl;
    for(int i=0; i<m1; i++){
        cout << t[apa[i]].sorszam << " ";
    }
    cout << endl;
    for(int i=0; i<m2; i++){
        cout << t[fia[i]].sorszam << " ";
    }
    cout << endl;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1744 KiB
2Accepted0/08ms2356 KiB
3Accepted1/13ms1992 KiB
4Accepted1/13ms2120 KiB
5Accepted2/23ms2332 KiB
6Accepted2/23ms2420 KiB
7Accepted2/23ms2564 KiB
8Accepted2/23ms2900 KiB
9Accepted3/33ms2924 KiB
10Accepted1/13ms2952 KiB
11Accepted1/13ms3100 KiB
12Accepted2/23ms3096 KiB
13Accepted2/23ms3076 KiB
14Accepted2/23ms3092 KiB
15Accepted2/23ms3092 KiB
16Accepted3/33ms3092 KiB
17Accepted2/279ms6948 KiB
18Accepted2/279ms6944 KiB
19Accepted4/479ms7152 KiB
20Accepted4/479ms7232 KiB
21Accepted4/481ms7448 KiB
22Accepted4/482ms7516 KiB
23Accepted4/487ms7412 KiB