31852023-02-21 19:15:22balaaaazsZsonglőrködéscpp14Wrong answer 0/1001.6s6868 KiB
#include <bits/stdc++.h>

using namespace std;

struct Interv{
    int e,v;

};

void kiir(vector<Interv> v)
{
    cout<<endl;
    for(Interv x:v)
        cout<<x.e<<"-"<<x.v<<endl;
    cout<<endl;
}

bool eszerint(Interv i1, Interv i2)
{
    if(i1.e!=i2.e)
        return i1.e<i2.e;
    else
        return i1.v<i2.v;
}

/*
9
1 3
8 10
1 7
2 7
2 3
9 11
2 4
3 9
3 8

*/
int main()
{
    int n;
    cin>>n;
    vector<Interv> musor(n);
    for(int i=0;i<n;i++)
        cin>>musor.at(i).e>>musor.at(i).v;
    sort(musor.begin(),musor.end(),eszerint);
    queue<Interv> sor;
    for(Interv x:musor)
        sor.push(x);
    sor.push(musor.at(0));
    Interv vege;
    vege.e=-1;
    vege.v=-1;
    sor.push(vege);
    Interv most;
    Interv uj;
    int szamlalo=0;
    while(sor.size()>1)
    {
        most=sor.front();
        sor.pop();
        //cout<<most.e<<"-"<<most.v<<" ";
        uj=sor.front();
        while(most.v > uj.e&&uj.e!=-1)
        {
            sor.push(uj);
            sor.pop();
            uj=sor.front();
        }
        if(uj.e==-1)
        {
            sor.pop();
            sor.push(uj);
            szamlalo++;
        }
        else if(uj.e==most.v){
            //cout<<uj.e<<"-"<<uj.v<<" ";
            sor.pop();
        }
    }
    cout<<szamlalo;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1680 KiB
2Wrong answer3ms1852 KiB
subtask20/20
3Wrong answer7ms2128 KiB
4Time limit exceeded1.575s2612 KiB
5Time limit exceeded1.572s4276 KiB
6Time limit exceeded1.569s4796 KiB
7Time limit exceeded1.559s5408 KiB
8Time limit exceeded1.6s5400 KiB
9Time limit exceeded1.539s5716 KiB
10Time limit exceeded1.575s5920 KiB
11Time limit exceeded1.557s6212 KiB
subtask30/35
12Wrong answer3ms3692 KiB
13Wrong answer3ms3808 KiB
14Wrong answer3ms3964 KiB
15Time limit exceeded1.6s3912 KiB
16Wrong answer4ms3804 KiB
17Wrong answer4ms3804 KiB
18Wrong answer4ms3912 KiB
19Time limit exceeded1.562s4000 KiB
20Wrong answer4ms4104 KiB
subtask40/45
21Wrong answer8ms4012 KiB
22Time limit exceeded1.6s4248 KiB
23Time limit exceeded1.583s6000 KiB
24Time limit exceeded1.567s6480 KiB
25Time limit exceeded1.572s6836 KiB
26Time limit exceeded1.572s6680 KiB
27Time limit exceeded1.572s6732 KiB
28Time limit exceeded1.575s6868 KiB
29Time limit exceeded1.575s6820 KiB