3186 | 2023-02-21 19:18:57 | balaaaazs | Zsonglőrködés | cpp14 | Wrong answer 0/100 | 1.6s | 7136 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 | 1808 KiB | ||||
2 | Wrong answer | 3ms | 2000 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 7ms | 2244 KiB | ||||
4 | Time limit exceeded | 1.6s | 2732 KiB | ||||
5 | Time limit exceeded | 1.583s | 4428 KiB | ||||
6 | Time limit exceeded | 1.567s | 5112 KiB | ||||
7 | Time limit exceeded | 1.572s | 5844 KiB | ||||
8 | Time limit exceeded | 1.575s | 6040 KiB | ||||
9 | Time limit exceeded | 1.585s | 6316 KiB | ||||
10 | Time limit exceeded | 1.567s | 6324 KiB | ||||
11 | Time limit exceeded | 1.555s | 6396 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Wrong answer | 3ms | 4036 KiB | ||||
13 | Wrong answer | 3ms | 4284 KiB | ||||
14 | Wrong answer | 3ms | 4280 KiB | ||||
15 | Time limit exceeded | 1.598s | 4256 KiB | ||||
16 | Wrong answer | 4ms | 4348 KiB | ||||
17 | Wrong answer | 4ms | 4232 KiB | ||||
18 | Wrong answer | 4ms | 4228 KiB | ||||
19 | Time limit exceeded | 1.598s | 4200 KiB | ||||
20 | Wrong answer | 4ms | 4232 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Wrong answer | 8ms | 4332 KiB | ||||
22 | Time limit exceeded | 1.552s | 4480 KiB | ||||
23 | Time limit exceeded | 1.569s | 5784 KiB | ||||
24 | Time limit exceeded | 1.56s | 6444 KiB | ||||
25 | Time limit exceeded | 1.557s | 6908 KiB | ||||
26 | Time limit exceeded | 1.567s | 7012 KiB | ||||
27 | Time limit exceeded | 1.577s | 6900 KiB | ||||
28 | Time limit exceeded | 1.57s | 7112 KiB | ||||
29 | Time limit exceeded | 1.572s | 7136 KiB |