88222024-01-31 16:47:09Tina0731Mekk Mester munkái (50 pont)cpp14Accepted 50/5093ms9256 KiB
#include <iostream>
#include <bits/stdc++.h>

using namespace std;

typedef struct {
    int k, v, index;
}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.index=i+1;
        munka.at(i)=uj;
    }

    sort(munka.begin(),munka.end(),Rendez);

    /*cout<<endl;
    for(Intervallum x : munka)
        cout<<x.k<<" "<<x.v<<" "<<x.index<<endl;*/

    int mekvege=0, fiavege=0;
    int mekdb=0, fiadb=0;
    vector<Intervallum> mek;
    vector<Intervallum> fia;
    for(int i=0;i<n;i++)
    {
        if(mekvege<munka.at(i).k && fiavege<munka.at(i).k)
        {
            if(mekvege>fiavege)
            {
                mekvege=munka.at(i).v;
                mekdb++;
                mek.push_back(munka.at(i));
            }
            else
            {
                fiavege=munka.at(i).v;
                fiadb++;
                fia.push_back(munka.at(i));

            }
        }
        else if(mekvege<munka.at(i).k)
        {
            mekvege=munka.at(i).v;
            mekdb++;
            mek.push_back(munka.at(i));
        }
        else if(fiavege<munka.at(i).k)
        {
            fiavege=munka.at(i).v;
            fiadb++;
            fia.push_back(munka.at(i));
        }

    }

    //sort(mek.begin(),mek.end());
    //sort(fia.begin(),fia.end());
    cout<<mekdb<<" "<<fiadb<<endl;
    for(Intervallum x : mek)
        cout<<x.index<<" ";
    cout<<endl;
    for(Intervallum x : fia)
        cout<<x.index<<" ";

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1812 KiB
2Accepted0/09ms2252 KiB
3Accepted1/13ms2220 KiB
4Accepted1/13ms2300 KiB
5Accepted2/23ms2296 KiB
6Accepted2/23ms2552 KiB
7Accepted2/23ms2788 KiB
8Accepted2/23ms3004 KiB
9Accepted3/33ms3000 KiB
10Accepted1/13ms3224 KiB
11Accepted1/13ms3328 KiB
12Accepted2/23ms3436 KiB
13Accepted2/23ms3528 KiB
14Accepted2/23ms3656 KiB
15Accepted2/24ms3876 KiB
16Accepted3/33ms3960 KiB
17Accepted2/283ms6540 KiB
18Accepted2/283ms6576 KiB
19Accepted4/483ms6472 KiB
20Accepted4/485ms6536 KiB
21Accepted4/485ms6896 KiB
22Accepted4/486ms7368 KiB
23Accepted4/493ms9256 KiB