QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#95601 | #4393. Snatch Groceries | Liberty12619# | AC ✓ | 48ms | 5160kb | C++20 | 672b | 2023-04-10 20:04:46 | 2023-04-10 20:04:47 |
Judging History
answer
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
#define int long long
#define x first
#define y second
using namespace std;
const int N = 1e5,INF = 1e12;
typedef pair<int,int> PII;
void solve()
{
int n;
cin>>n;
vector<PII>regs(n+5);
for(int i=1;i<=n;i++) scanf("%lld%lld",®s[i].x,®s[i].y);
sort(regs.begin()+1,regs.begin()+n+1);
if(n==1)
{
cout<<1<<endl;
return;
}
int r = -1,ans=n;
for(int i=1;i<=n;i++)
{
if(regs[i].x<=r)
{
ans=i-2;
break;
}
r=max(r,regs[i].y);
}
cout<<ans<<endl;
}
signed main()
{
int T = 1;
cin>>T;
while(T--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 48ms
memory: 5160kb
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