3188 | 2023-02-21 19:27:23 | balaaaazs | Zsonglőrködés | cpp14 | Wrong answer 0/100 | 1.6s | 7184 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 | 1812 KiB | ||||
2 | Wrong answer | 3ms | 2056 KiB | ||||
subtask2 | 0/20 | ||||||
3 | Wrong answer | 7ms | 2248 KiB | ||||
4 | Time limit exceeded | 1.55s | 2880 KiB | ||||
5 | Time limit exceeded | 1.567s | 4476 KiB | ||||
6 | Time limit exceeded | 1.58s | 4968 KiB | ||||
7 | Time limit exceeded | 1.572s | 5308 KiB | ||||
8 | Time limit exceeded | 1.583s | 5604 KiB | ||||
9 | Time limit exceeded | 1.532s | 5776 KiB | ||||
10 | Time limit exceeded | 1.572s | 5988 KiB | ||||
11 | Time limit exceeded | 1.583s | 6072 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Wrong answer | 3ms | 3780 KiB | ||||
13 | Wrong answer | 3ms | 4008 KiB | ||||
14 | Wrong answer | 3ms | 4096 KiB | ||||
15 | Time limit exceeded | 1.555s | 3840 KiB | ||||
16 | Wrong answer | 4ms | 4000 KiB | ||||
17 | Wrong answer | 4ms | 3984 KiB | ||||
18 | Wrong answer | 4ms | 4096 KiB | ||||
19 | Time limit exceeded | 1.6s | 4184 KiB | ||||
20 | Wrong answer | 4ms | 4248 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Wrong answer | 8ms | 4376 KiB | ||||
22 | Time limit exceeded | 1.6s | 4540 KiB | ||||
23 | Time limit exceeded | 1.56s | 6088 KiB | ||||
24 | Time limit exceeded | 1.544s | 6704 KiB | ||||
25 | Time limit exceeded | 1.56s | 6880 KiB | ||||
26 | Time limit exceeded | 1.577s | 6876 KiB | ||||
27 | Time limit exceeded | 1.555s | 7184 KiB | ||||
28 | Time limit exceeded | 1.567s | 7140 KiB | ||||
29 | Time limit exceeded | 1.569s | 7152 KiB |