31832023-02-21 16:27:39balaaaazsZsonglőrködéscpp14Wrong answer 0/1001.6s7260 KiB
#include <bits/stdc++.h>
using namespace std;
typedef struct{
    int e;
    int v;
    //bool volte=false;
} Interv;
/*
5
1 5
4 5
5 8
5 9
1 9
*/
/*
9
1 3
8 10
1 7
2 7
2 3
9 11
2 4
3 9
3 8
*/
bool eszerint(Interv i1, Interv i2)
{
    if (i1.e!=i2.e)
       return i1.e<i2.e;
    else
       return i1.v<i2.v;
}
void qkiir(queue<Interv> q)
{
    queue<Interv> seged=q;
    Interv v;
    while(!seged.empty())
    {
        v=seged.front();
        cout<<v.e<<".."<<v.v<<" ";
        seged.pop();
    }
    cout<<endl;
}

int main()
{
    int szamlalo=0;
    int n;
    cin>>n;
    vector<Interv> musor(n);
    for(int i=0;i<n;i++)
    {
        cin>>musor.at(i).e>>musor.at(i).v;
    }
/*
    for(Interv x: musor)
        cout<<x.e<<"-"<<x.v<<" ";
*/
    cout<<endl;

    sort(musor.begin(),musor.end(),eszerint);
    //for(Interv x: musor)
    //    cout<<x.e<<"-"<<x.v<<endl;

    queue <Interv> sor;
    Interv jelol,most,uj;
    jelol.e=-1;
    jelol.v=-1;
    for(Interv x: musor)
    {
        sor.push(x);
    }
    uj=jelol;
    sor.push(uj);


    while(sor.size()>1)
    {
        if(uj.e==-1)
        {
            most=sor.front();
            sor.pop();
            //cout<<endl<<most.e<<"--"<<most.v<<"  ";
        }
        else
        {
            most=uj;

        }
        uj=sor.front();
        sor.pop();


        while(most.v>uj.e && uj.e!=-1)
        {
            sor.push(uj);

            uj=sor.front();
            sor.pop();
            //qkiir(sor);
        }
        if(most.v==uj.e)
        {
           //cout<<uj.e<<"--"<<uj.v<<" ";
        }
        else if(most.v<uj.e)
        {
            while(uj.e!=-1)
                {
                    sor.push(uj);
                    uj=sor.front();
                    sor.pop();
            }
        }
        if(uj.e==-1){
            sor.push(uj);
            szamlalo++;
        }
    }
    cout<<szamlalo;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1812 KiB
2Wrong answer3ms2056 KiB
subtask20/20
3Wrong answer12ms2244 KiB
4Time limit exceeded1.6s2588 KiB
5Time limit exceeded1.555s4268 KiB
6Time limit exceeded1.567s4936 KiB
7Time limit exceeded1.555s5608 KiB
8Time limit exceeded1.6s5520 KiB
9Time limit exceeded1.57s5816 KiB
10Time limit exceeded1.56s6156 KiB
11Time limit exceeded1.575s6020 KiB
subtask30/35
12Wrong answer3ms3540 KiB
13Wrong answer3ms3652 KiB
14Wrong answer3ms3692 KiB
15Wrong answer3ms3944 KiB
16Wrong answer4ms4088 KiB
17Wrong answer4ms4140 KiB
18Wrong answer4ms4032 KiB
19Wrong answer4ms4208 KiB
20Wrong answer4ms4224 KiB
subtask40/45
21Wrong answer12ms4492 KiB
22Time limit exceeded1.565s4500 KiB
23Time limit exceeded1.559s6056 KiB
24Time limit exceeded1.572s6524 KiB
25Time limit exceeded1.552s6904 KiB
26Time limit exceeded1.559s6960 KiB
27Time limit exceeded1.58s6880 KiB
28Time limit exceeded1.536s7028 KiB
29Time limit exceeded1.524s7260 KiB