QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711729 | #4393. Snatch Groceries | hejinming983282# | AC ✓ | 120ms | 4800kb | C++14 | 718b | 2024-11-05 13:10:57 | 2024-11-05 13:10:57 |
Judging History
answer
#include<iostream>
#include<algorithm>
using namespace std;
struct tie{
int e;
int l;
int qs;
};
bool cmp(tie w,tie s)
{
if(w.e==s.e)
{
if(w.l==s.l) return w.qs<s.qs;
else return w.l>s.l;}
return w.e<s.e;
}
int main()
{
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
tie q[100001];
for(int i=1;i<=n;i++)
{
cin>>q[i].e>>q[i].l;
q[i].qs=i;
}
sort(q,q+n,cmp);
int sum=0,f=0;
for(int i=1;i<=n;i++)
{
if(q[i+1].e<=q[i].l&&i+1<=n)
{
f=1;
break;
}
if(!f) sum=sum+1;
//cout<<sum<<endl;
}
/*if(!f)
{
if(q[n].e>q[n-1].l) sum++;
}*/
if(n==1) sum=1;
cout<<sum<<endl;
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 120ms
memory: 4800kb
input:
5 3 1 2 3 4 5 6 3 1 2 3 4 4 5 100000 263324740 263324748 920719069 920719077 82595123 82595132 765796214 765796222 621714954 621714959 77799324 77799332 278166427 278166428 375391536 375391545 856576804 856576812 512542774 512542781 829984452 829984457 302442403 302442404 779239984 779239986 1189173...
output:
3 1 275 5575 10000
result:
ok 5 lines