204382026-01-06 18:28:58SomogyiMekk Mester munkái (50 pont)cpp17Accepted 50/5089ms2268 KiB
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

bool hasonlit (munka a, munka b)
{
    return a.v<b.v;
}

int main()
{
    int n ,p;
    cin >> n >> p;
    vector <munka> m(n);
    for (int i=0; i<n; i++)
    {
        cin >> m[i].k >> m[i].v;
        m[i].ind=i+1;
    }
    sort(m.begin(),m.end(),hasonlit);

    vector <int> apa, fiu;
    int vegea=0, vegef=0;
    bool a,f;
    for (int i=0; i<n; i++)
    {
        a=(m[i].k>vegea);
        f=(m[i].k>vegef);
        if (a && f)
        {
            if (vegea>vegef)
            {
                apa.push_back(m[i].ind);
                vegea=m[i].v;
            }
            else
            {
                fiu.push_back(m[i].ind);
                vegef=m[i].v;
            }
        }
        else
        {
            if (a)
            {
                apa.push_back(m[i].ind);
                vegea=m[i].v;
            }
            else
            {
                if (f)
                {
                    fiu.push_back(m[i].ind);
                    vegef=m[i].v;
                }
            }
        }
    }

    cout << apa.size() << " " << fiu.size() << endl;
    for (int x : apa)
    {
        cout << x << " ";
    }
    cout << endl;
    for (int x:fiu)
    {
        cout << x << " ";
    }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/01ms500 KiB
2Accepted0/08ms508 KiB
3Accepted1/11ms316 KiB
4Accepted1/11ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms404 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Accepted1/11ms388 KiB
11Accepted1/12ms500 KiB
12Accepted2/22ms412 KiB
13Accepted2/22ms316 KiB
14Accepted2/22ms316 KiB
15Accepted2/22ms316 KiB
16Accepted3/32ms316 KiB
17Accepted2/279ms1580 KiB
18Accepted2/279ms1588 KiB
19Accepted4/479ms1580 KiB
20Accepted4/479ms1588 KiB
21Accepted4/479ms1584 KiB
22Accepted4/482ms1600 KiB
23Accepted4/489ms2268 KiB