88172024-01-31 16:27:35Tina0731Mekk Mester munkái (50 pont)cpp14Wrong answer 1/5093ms7628 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
base1/50
1Accepted0/03ms1812 KiB
2Wrong answer0/09ms2308 KiB
3Accepted1/13ms2140 KiB
4Wrong answer0/13ms2112 KiB
5Wrong answer0/23ms2320 KiB
6Wrong answer0/23ms2564 KiB
7Wrong answer0/23ms2736 KiB
8Wrong answer0/23ms2824 KiB
9Wrong answer0/33ms2956 KiB
10Wrong answer0/13ms3076 KiB
11Wrong answer0/13ms3304 KiB
12Wrong answer0/23ms3288 KiB
13Wrong answer0/23ms3288 KiB
14Wrong answer0/23ms3428 KiB
15Wrong answer0/23ms3508 KiB
16Wrong answer0/33ms3612 KiB
17Wrong answer0/282ms5752 KiB
18Wrong answer0/282ms5812 KiB
19Wrong answer0/483ms5872 KiB
20Wrong answer0/483ms5936 KiB
21Wrong answer0/485ms6292 KiB
22Wrong answer0/486ms6488 KiB
23Wrong answer0/493ms7628 KiB