85982024-01-23 06:40:45BenedekMartonMekk Mester munkái (50 pont)cpp17Accepted 50/5090ms7396 KiB
#include <iostream>
//#include <queue>
#include <algorithm>

using namespace std;

struct kv
{
    int k;
    int v;
    int ind;
};

bool f(kv a, kv b)
{
    if(a.v==b.v)
    {
        return a.k>b.k;
    }
    return a.v<b.v;
}

int main()
{
    int n, h;
    cin >> n >> h;
    kv mun[n];
    for(int i=0; i<n; i++)
    {
        cin >> mun[i].k >> mun[i].v;
        mun[i].ind=i+1;
    }
    //queue<int> q1, q2;
    sort(mun, mun+n, f);
    int uccso1=0, uccso2=0, sz1=0, sz2=0, muel[n];
    for(int i=0; i<n; i++)
    {
        if(uccso2>uccso1)
            {
                if(uccso2<mun[i].k)
            {
                muel[i]=2;
                uccso2=mun[i].v;
                sz2++;
            }
            else if(uccso1<mun[i].k)
            {
                muel[i]=1;
                uccso1=mun[i].v;
                sz1++;
            }
            else
            {
                muel[i]=0;
            }
        }
        else
        {
            if(uccso1<mun[i].k)
            {
                muel[i]=1;
                uccso1=mun[i].v;
                sz1++;
            }
            else if(uccso2<mun[i].k)
            {
                muel[i]=2;
                uccso2=mun[i].v;
                sz2++;
            }
            else
            {
                muel[i]=0;
            }
        }

    }
    cout << sz1 << " " << sz2 << endl;
    for(int i=0; i<n; i++)
    {
        if(muel[i]==1)
        {
            cout << mun[i].ind << " ";
        }
    }
    cout << endl;
    for(int i=0; i<n; i++)
    {
        if(muel[i]==2)
        {
            cout << mun[i].ind << " ";
        }
    }
    cout << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1872 KiB
2Accepted0/08ms2408 KiB
3Accepted1/13ms2336 KiB
4Accepted1/13ms2392 KiB
5Accepted2/23ms2488 KiB
6Accepted2/23ms2852 KiB
7Accepted2/23ms2756 KiB
8Accepted2/23ms2944 KiB
9Accepted3/33ms3156 KiB
10Accepted1/14ms3400 KiB
11Accepted1/13ms3452 KiB
12Accepted2/23ms3596 KiB
13Accepted2/23ms3668 KiB
14Accepted2/23ms3676 KiB
15Accepted2/23ms3680 KiB
16Accepted3/33ms3804 KiB
17Accepted2/282ms7000 KiB
18Accepted2/282ms6976 KiB
19Accepted4/482ms6972 KiB
20Accepted4/482ms6976 KiB
21Accepted4/482ms7104 KiB
22Accepted4/485ms7312 KiB
23Accepted4/490ms7396 KiB