QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#340537#4393. Snatch Groceriescrsfaa#AC ✓18ms4628kbC++14731b2024-02-29 09:53:552024-02-29 09:53:56

Judging History

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

  • [2024-02-29 09:53:56]
  • 评测
  • 测评结果:AC
  • 用时:18ms
  • 内存:4628kb
  • [2024-02-29 09:53:55]
  • 提交

answer

#include<bits/stdc++.h>
#define Yukinoshita namespace
#define Yukino std
using Yukinoshita Yukino;
int read()
{
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0'||ch>'9') w=ch=='-'?-1:1,ch=getchar();
	while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
	return s*w;
}
const int mxn=1e5+5;
pair<int,int> a[mxn];
/*
100
5
1 2
3 4
5 6
6 7
4 4
*/
int main()
{
	int T=read();
	while(T--)
	{
		int n=read(),i,j,mx=-1,ans=n;
		for(i=1;i<=n;i++)
			a[i].first=read(),a[i].second=read();
		sort(a+1,a+1+n);
		for(i=1;i<=n;i++)
		{
			if(a[i].first<=mx)
			{
				ans=0;
				for(j=1;j<i;j++)
					ans+=a[j].second<a[i].first;
				break;
			}
			mx=max(mx,a[i].second);
		}
		printf("%d\n",ans);
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 18ms
memory: 4628kb

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