204322026-01-06 18:19:33PappMatyasMekk Mester munkái (50 pont)cpp17Accepted 50/5086ms2264 KiB
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

struct Work
{
    int s, e, idx;
};

static bool Compare(Work a, Work b)
{
    return a.e < b.e;
}

int main()
{
    int n, k;
    cin >> n >> k;

    vector <Work> workList(n);

    for (int i = 0; i < n; i++)
    {
        cin >> workList[i].s >> workList[i].e;
        workList[i].idx = i;
    }

    sort(workList.begin(), workList.end(), Compare);

    vector<int> aAns;
    vector<int> bAns;

    int aEnd = 0;
    int bEnd = 0;

    bool aAnsCurrent;
    bool bAnsCurrent;

    int aCount = 0;
    int bCount = 0;

    for (int i = 0; i < n; i++)
    {
        aAnsCurrent = (workList[i].s > aEnd);
        bAnsCurrent = (workList[i].s > bEnd);
        if (aAnsCurrent && bAnsCurrent)
        {
            if (aEnd > bEnd)
            {
                aAns.push_back(workList[i].idx + 1);
                aCount++;
                aEnd = workList[i].e;
            }
            else
            {
                bAns.push_back(workList[i].idx + 1);
                bCount++;
                bEnd = workList[i].e;
            }
        }
        else
        {
            if (aAnsCurrent)
            {
                aAns.push_back(workList[i].idx + 1);
                aCount++;
                aEnd = workList[i].e;
            }
            else
            {
                if (bAnsCurrent)
                {
                    bAns.push_back(workList[i].idx + 1);
                    bCount++;
                    bEnd = workList[i].e;
                }
            }
        }
    }

    cout << aCount << " " << bCount << endl;

    for (int x : aAns)
    {
        cout << x << " ";
    }
    cout << endl;

    for (int x : bAns)
    {
        cout << x << " ";
    }
    cout << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/02ms316 KiB
2Accepted0/08ms316 KiB
3Accepted1/11ms508 KiB
4Accepted1/11ms508 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms316 KiB
9Accepted3/31ms316 KiB
10Accepted1/12ms316 KiB
11Accepted1/12ms316 KiB
12Accepted2/22ms508 KiB
13Accepted2/22ms316 KiB
14Accepted2/21ms392 KiB
15Accepted2/22ms508 KiB
16Accepted3/32ms316 KiB
17Accepted2/279ms1588 KiB
18Accepted2/276ms1584 KiB
19Accepted4/478ms1580 KiB
20Accepted4/478ms1584 KiB
21Accepted4/478ms1592 KiB
22Accepted4/479ms1588 KiB
23Accepted4/486ms2264 KiB