87562024-01-28 23:09:12AncsaMekk Mester munkái (50 pont)cpp17Accepted 50/50217ms8268 KiB
#include <bits/stdc++.h>

using namespace std;

/*
Be:
10 14
3 10
1 7
3 1
10 12
3 9
4 5
6 6
8 10
10 13
3 7

*/


typedef struct {
   int eleje, vege, sorszam;
}Tartam;



bool sorrend (Tartam egyik, Tartam masik )
{
    return (egyik.vege<masik.vege);
}

int main()
{
    int n, napok;
    cin>>n;  //megrendelesek
    cin>>napok; //a napok szama

    vector<Tartam> intervallum;
    Tartam uj;
    for(int i=1;i<=n;i++)
    {
        cin>> uj.eleje>>uj.vege;
        uj.sorszam=i;
        intervallum.push_back(uj);
    }
   
    sort(intervallum.begin(),intervallum.end(),sorrend);

    vector <Tartam> mester;
    vector <Tartam> fia;
    int autolso=0, futolso=0;
    int i=0;
    int fszam=0, aszam=0;
    while (i<n)
    {
       Tartam x=intervallum.at(i);
       if (x.eleje>autolso && x.eleje>futolso)
       {
           if (x.eleje-autolso > x.eleje-futolso)
           {
              fia.push_back(x);
              futolso=x.vege;
              fszam++;
           }
           else
           {
               mester.push_back(x);
               autolso=x.vege;
               aszam++;
           }
       }
       else if (x.eleje>futolso)
       {
           fia.push_back(x);
           futolso=x.vege;
           fszam++;
       }
       else if (x.eleje > autolso)
       {
           mester.push_back(x);
           autolso=x.vege;
           aszam++;
       }
       i++;
    }
    cout<<aszam<<" "<<fszam<<endl;

    for(Tartam x:mester)
        cout <<x.sorszam<< endl;
    for(Tartam x:fia)
        cout <<x.sorszam<< endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/03ms1708 KiB
2Accepted0/09ms2480 KiB
3Accepted1/13ms2116 KiB
4Accepted1/13ms2332 KiB
5Accepted2/23ms2536 KiB
6Accepted2/23ms2624 KiB
7Accepted2/23ms2752 KiB
8Accepted2/23ms2836 KiB
9Accepted3/33ms2848 KiB
10Accepted1/13ms2980 KiB
11Accepted1/13ms2992 KiB
12Accepted2/23ms3076 KiB
13Accepted2/23ms3072 KiB
14Accepted2/24ms3080 KiB
15Accepted2/24ms3088 KiB
16Accepted3/34ms3232 KiB
17Accepted2/285ms6320 KiB
18Accepted2/286ms6448 KiB
19Accepted4/487ms6456 KiB
20Accepted4/487ms6460 KiB
21Accepted4/492ms6460 KiB
22Accepted4/4105ms6464 KiB
23Accepted4/4217ms8268 KiB