31862023-02-21 19:18:57balaaaazsZsonglőrködéscpp14Wrong answer 0/1001.6s7136 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 answer3ms2000 KiB
subtask20/20
3Wrong answer7ms2244 KiB
4Time limit exceeded1.6s2732 KiB
5Time limit exceeded1.583s4428 KiB
6Time limit exceeded1.567s5112 KiB
7Time limit exceeded1.572s5844 KiB
8Time limit exceeded1.575s6040 KiB
9Time limit exceeded1.585s6316 KiB
10Time limit exceeded1.567s6324 KiB
11Time limit exceeded1.555s6396 KiB
subtask30/35
12Wrong answer3ms4036 KiB
13Wrong answer3ms4284 KiB
14Wrong answer3ms4280 KiB
15Time limit exceeded1.598s4256 KiB
16Wrong answer4ms4348 KiB
17Wrong answer4ms4232 KiB
18Wrong answer4ms4228 KiB
19Time limit exceeded1.598s4200 KiB
20Wrong answer4ms4232 KiB
subtask40/45
21Wrong answer8ms4332 KiB
22Time limit exceeded1.552s4480 KiB
23Time limit exceeded1.569s5784 KiB
24Time limit exceeded1.56s6444 KiB
25Time limit exceeded1.557s6908 KiB
26Time limit exceeded1.567s7012 KiB
27Time limit exceeded1.577s6900 KiB
28Time limit exceeded1.57s7112 KiB
29Time limit exceeded1.572s7136 KiB