88232024-01-31 16:47:47KCsengeMekk Mester munkái (50 pont)cpp14Accepted 50/5090ms6884 KiB
#include <iostream>
#include <bits/stdc++.h>
/*
10 14
2 4
1 7
7 12
10 12
3 9
4 5
6 6
8 10
10 13
3 7
*/
using namespace std;

typedef struct
{
    int k,v,ind;
} Intervallum;

bool rendez(Intervallum i1,Intervallum i2)
{
    return i1.v<i2.v;
}

int main()
{
    int n,napok;
    cin>>n>>napok;
    vector<Intervallum> Munka(n);
    Intervallum uj;
    for(int i=0;i<n;i++)
    {
        cin>>uj.k>>uj.v;
        uj.ind=i+1;
        Munka.at(i)=uj;
    }
    /*
    for(Intervallum x: Munka)
    {
        cout<<x.k<< " "<<x.v<<" "<<x.ind<<endl;
    }
    */

    sort(Munka.begin(),Munka.end(),rendez);
    /*
    cout<< endl;
    for(Intervallum x: Munka)
    {
        cout<<x.k<< " "<<x.v<<" "<<x.ind<<endl;
    }
    */
    int mesvege=0,fiavege=0,m=0,f=0;
    vector<int> mekk;
    vector<int> fia;
    for(int i=0;i<n;i++)
    {
            if (Munka[i].k>mesvege && Munka[i].k>fiavege)
            {
                if(mesvege<fiavege)
                {
                    fiavege=Munka[i].v;
                    f++;
                    fia.push_back(Munka[i].ind);
                }
                if(mesvege>=fiavege)
                {
                    mesvege=Munka[i].v;
                    m++;
                    mekk.push_back(Munka[i].ind);
                }
            }
            else if(Munka[i].k>mesvege)
            {
                mesvege=Munka[i].v;
                m++;
                mekk.push_back(Munka[i].ind);
            }
            else if(Munka[i].k>fiavege)
            {
                fiavege=Munka[i].v;
                f++;
                fia.push_back(Munka[i].ind);
            }
    }
    cout<<m<<" "<<f<<endl;
    for(int x : mekk)
        cout<<x<<" ";
    cout<<endl;
    for(int x : fia)
        cout<<x<<" ";
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1960 KiB
2Accepted0/08ms2444 KiB
3Accepted1/13ms2416 KiB
4Accepted1/13ms2688 KiB
5Accepted2/23ms2600 KiB
6Accepted2/23ms2724 KiB
7Accepted2/23ms2972 KiB
8Accepted2/23ms3152 KiB
9Accepted3/33ms3344 KiB
10Accepted1/13ms3444 KiB
11Accepted1/13ms3568 KiB
12Accepted2/23ms3568 KiB
13Accepted2/23ms3700 KiB
14Accepted2/23ms3776 KiB
15Accepted2/23ms3876 KiB
16Accepted3/33ms3796 KiB
17Accepted2/281ms5944 KiB
18Accepted2/281ms5944 KiB
19Accepted4/482ms5940 KiB
20Accepted4/482ms5944 KiB
21Accepted4/482ms6084 KiB
22Accepted4/482ms6232 KiB
23Accepted4/490ms6884 KiB