3183 | 2023-02-21 16:27:39 | balaaaazs | Zsonglőrködés | cpp14 | Wrong answer 0/100 | 1.6s | 7260 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef struct{
int e;
int v;
//bool volte=false;
} Interv;
/*
5
1 5
4 5
5 8
5 9
1 9
*/
/*
9
1 3
8 10
1 7
2 7
2 3
9 11
2 4
3 9
3 8
*/
bool eszerint(Interv i1, Interv i2)
{
if (i1.e!=i2.e)
return i1.e<i2.e;
else
return i1.v<i2.v;
}
void qkiir(queue<Interv> q)
{
queue<Interv> seged=q;
Interv v;
while(!seged.empty())
{
v=seged.front();
cout<<v.e<<".."<<v.v<<" ";
seged.pop();
}
cout<<endl;
}
int main()
{
int szamlalo=0;
int n;
cin>>n;
vector<Interv> musor(n);
for(int i=0;i<n;i++)
{
cin>>musor.at(i).e>>musor.at(i).v;
}
/*
for(Interv x: musor)
cout<<x.e<<"-"<<x.v<<" ";
*/
cout<<endl;
sort(musor.begin(),musor.end(),eszerint);
//for(Interv x: musor)
// cout<<x.e<<"-"<<x.v<<endl;
queue <Interv> sor;
Interv jelol,most,uj;
jelol.e=-1;
jelol.v=-1;
for(Interv x: musor)
{
sor.push(x);
}
uj=jelol;
sor.push(uj);
while(sor.size()>1)
{
if(uj.e==-1)
{
most=sor.front();
sor.pop();
//cout<<endl<<most.e<<"--"<<most.v<<" ";
}
else
{
most=uj;
}
uj=sor.front();
sor.pop();
while(most.v>uj.e && uj.e!=-1)
{
sor.push(uj);
uj=sor.front();
sor.pop();
//qkiir(sor);
}
if(most.v==uj.e)
{
//cout<<uj.e<<"--"<<uj.v<<" ";
}
else if(most.v<uj.e)
{
while(uj.e!=-1)
{
sor.push(uj);
uj=sor.front();
sor.pop();
}
}
if(uj.e==-1){
sor.push(uj);
szamlalo++;
}
}
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 | 12ms | 2244 KiB | ||||
4 | Time limit exceeded | 1.6s | 2588 KiB | ||||
5 | Time limit exceeded | 1.555s | 4268 KiB | ||||
6 | Time limit exceeded | 1.567s | 4936 KiB | ||||
7 | Time limit exceeded | 1.555s | 5608 KiB | ||||
8 | Time limit exceeded | 1.6s | 5520 KiB | ||||
9 | Time limit exceeded | 1.57s | 5816 KiB | ||||
10 | Time limit exceeded | 1.56s | 6156 KiB | ||||
11 | Time limit exceeded | 1.575s | 6020 KiB | ||||
subtask3 | 0/35 | ||||||
12 | Wrong answer | 3ms | 3540 KiB | ||||
13 | Wrong answer | 3ms | 3652 KiB | ||||
14 | Wrong answer | 3ms | 3692 KiB | ||||
15 | Wrong answer | 3ms | 3944 KiB | ||||
16 | Wrong answer | 4ms | 4088 KiB | ||||
17 | Wrong answer | 4ms | 4140 KiB | ||||
18 | Wrong answer | 4ms | 4032 KiB | ||||
19 | Wrong answer | 4ms | 4208 KiB | ||||
20 | Wrong answer | 4ms | 4224 KiB | ||||
subtask4 | 0/45 | ||||||
21 | Wrong answer | 12ms | 4492 KiB | ||||
22 | Time limit exceeded | 1.565s | 4500 KiB | ||||
23 | Time limit exceeded | 1.559s | 6056 KiB | ||||
24 | Time limit exceeded | 1.572s | 6524 KiB | ||||
25 | Time limit exceeded | 1.552s | 6904 KiB | ||||
26 | Time limit exceeded | 1.559s | 6960 KiB | ||||
27 | Time limit exceeded | 1.58s | 6880 KiB | ||||
28 | Time limit exceeded | 1.536s | 7028 KiB | ||||
29 | Time limit exceeded | 1.524s | 7260 KiB |