QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#73194 | #4393. Snatch Groceries | LiCooer | AC ✓ | 133ms | 4976kb | C++17 | 975b | 2023-01-23 00:01:27 | 2023-01-23 00:01:28 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 101000;
struct node
{
int l , r;
}a[N];
bool cmp(const node A , const node B)
{
if(A.l != B.l)
{
return A.l < B.l;
}
return A.r > B.r;
}
signed main()
{
int t;
cin >> t;
while(t -- )
{
int n;
cin >> n;
for(int i = 1 ; i <= n ; i ++ )
{
cin >> a[i].l >> a[i].r;
}
sort(a + 1 , a + 1 + n , cmp);
int max1 = a[1].r;
int ans = 0;
for(int i = 2 ; i <= n ; i ++ )
{
if(a[i].l <= max1)
{
break;
}
else
{
max1 = max(a[i].r , max1);
ans ++;
}
}
if(ans == n - 1)
{
ans ++ ;
}
cout << ans << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 133ms
memory: 4976kb
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