3185 | 2023-02-21 19:15:22 | balaaaazs | Zsonglőrködés | cpp14 | Wrong answer 0/100 | 1.6s | 6868 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;
}
Subtask | Sum | Test | Verdict | Time | Memory | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Wrong answer | 3ms | 1680 KiB | ||||
2 | Wrong answer | 3ms | 1852 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 7ms | 2128 KiB | ||||
4 | Time limit exceeded | 1.575s | 2612 KiB | ||||
5 | Time limit exceeded | 1.572s | 4276 KiB | ||||
6 | Time limit exceeded | 1.569s | 4796 KiB | ||||
7 | Time limit exceeded | 1.559s | 5408 KiB | ||||
8 | Time limit exceeded | 1.6s | 5400 KiB | ||||
9 | Time limit exceeded | 1.539s | 5716 KiB | ||||
10 | Time limit exceeded | 1.575s | 5920 KiB | ||||
11 | Time limit exceeded | 1.557s | 6212 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Wrong answer | 3ms | 3692 KiB | ||||
13 | Wrong answer | 3ms | 3808 KiB | ||||
14 | Wrong answer | 3ms | 3964 KiB | ||||
15 | Time limit exceeded | 1.6s | 3912 KiB | ||||
16 | Wrong answer | 4ms | 3804 KiB | ||||
17 | Wrong answer | 4ms | 3804 KiB | ||||
18 | Wrong answer | 4ms | 3912 KiB | ||||
19 | Time limit exceeded | 1.562s | 4000 KiB | ||||
20 | Wrong answer | 4ms | 4104 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Wrong answer | 8ms | 4012 KiB | ||||
22 | Time limit exceeded | 1.6s | 4248 KiB | ||||
23 | Time limit exceeded | 1.583s | 6000 KiB | ||||
24 | Time limit exceeded | 1.567s | 6480 KiB | ||||
25 | Time limit exceeded | 1.572s | 6836 KiB | ||||
26 | Time limit exceeded | 1.572s | 6680 KiB | ||||
27 | Time limit exceeded | 1.572s | 6732 KiB | ||||
28 | Time limit exceeded | 1.575s | 6868 KiB | ||||
29 | Time limit exceeded | 1.575s | 6820 KiB |