29992023-02-07 21:13:33balaaaazsZsonglőrködéscpp14Wrong answer 0/1001.6s6716 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 answer3ms1808 KiB
2Wrong answer3ms2008 KiB
subtask20/20
3Wrong answer7ms2276 KiB
4Time limit exceeded1.564s2476 KiB
5Time limit exceeded1.559s4136 KiB
6Time limit exceeded1.578s4888 KiB
7Time limit exceeded1.559s5408 KiB
8Time limit exceeded1.575s5552 KiB
9Time limit exceeded1.572s5796 KiB
10Time limit exceeded1.546s5760 KiB
11Time limit exceeded1.572s5964 KiB
subtask30/35
12Wrong answer3ms3364 KiB
13Wrong answer3ms3600 KiB
14Wrong answer3ms3816 KiB
15Time limit exceeded1.6s3872 KiB
16Wrong answer4ms3916 KiB
17Wrong answer4ms3800 KiB
18Wrong answer4ms3828 KiB
19Time limit exceeded1.6s3868 KiB
20Wrong answer4ms4008 KiB
subtask40/45
21Wrong answer7ms4124 KiB
22Time limit exceeded1.547s4260 KiB
23Time limit exceeded1.567s5740 KiB
24Time limit exceeded1.555s6476 KiB
25Time limit exceeded1.555s6716 KiB
26Time limit exceeded1.58s6580 KiB
27Time limit exceeded1.546s6636 KiB
28Time limit exceeded1.565s6592 KiB
29Time limit exceeded1.564s6624 KiB