31882023-02-21 19:27:23balaaaazsZsonglőrködéscpp14Wrong answer 0/1001.6s7184 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 answer3ms1812 KiB
2Wrong answer3ms2056 KiB
subtask20/20
3Wrong answer7ms2248 KiB
4Time limit exceeded1.55s2880 KiB
5Time limit exceeded1.567s4476 KiB
6Time limit exceeded1.58s4968 KiB
7Time limit exceeded1.572s5308 KiB
8Time limit exceeded1.583s5604 KiB
9Time limit exceeded1.532s5776 KiB
10Time limit exceeded1.572s5988 KiB
11Time limit exceeded1.583s6072 KiB
subtask30/35
12Wrong answer3ms3780 KiB
13Wrong answer3ms4008 KiB
14Wrong answer3ms4096 KiB
15Time limit exceeded1.555s3840 KiB
16Wrong answer4ms4000 KiB
17Wrong answer4ms3984 KiB
18Wrong answer4ms4096 KiB
19Time limit exceeded1.6s4184 KiB
20Wrong answer4ms4248 KiB
subtask40/45
21Wrong answer8ms4376 KiB
22Time limit exceeded1.6s4540 KiB
23Time limit exceeded1.56s6088 KiB
24Time limit exceeded1.544s6704 KiB
25Time limit exceeded1.56s6880 KiB
26Time limit exceeded1.577s6876 KiB
27Time limit exceeded1.555s7184 KiB
28Time limit exceeded1.567s7140 KiB
29Time limit exceeded1.569s7152 KiB