QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#280206#4393. Snatch GrocerieschunzhifengAC ✓34ms4512kbC++14615b2023-12-09 14:25:222023-12-09 14:25:24

Judging History

你现在查看的是最新测评结果

  • [2023-12-09 14:25:24]
  • 评测
  • 测评结果:AC
  • 用时:34ms
  • 内存:4512kb
  • [2023-12-09 14:25:22]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define endl "\n"
#define PII pair<int,int>
const ll INF=0x3f3f3f3f3f3f3f3f;
const int mod=998244353;
const int N=4e5+5;
struct Node{
	int l,r;
}a[N];
void solve(){
	int n; cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i].l>>a[i].r;
	sort(a+1,a+1+n,[&](Node &t1,Node &t2){
		return t1.l<t2.l;
	});
	for(int i=2;i<=n;i++){
		if(a[i].l<=a[i-1].r){
			cout<<i-2<<endl; return;
		} 
	} cout<<n<<endl;
}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int T=1; cin>>T;
    while(T--) solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 34ms
memory: 4512kb

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