QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#251847#4393. Snatch GroceriesPZhengWA 129ms5060kbC++14656b2023-11-15 10:40:562023-11-15 10:40:56

Judging History

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

  • [2023-11-15 10:40:56]
  • 评测
  • 测评结果:WA
  • 用时:129ms
  • 内存:5060kb
  • [2023-11-15 10:40:56]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
struct node
{
	int p,x;
	bool operator<(node nod)const 
	{
		if(p!=nod.p)
			return p<nod.p;
		else
			return x<nod.x;
	}
};
void solve()
{
	int n,cnt=0,now=0;
	cin>>n;
	vector<node> nods(n*2);
	for(int i=0;i<n;i++){
		cin>>nods[i*2].p>>nods[i*2+1].p;
		nods[i*2].x=1;
		nods[i*2+1].x=-1;
	}
	sort(nods.begin(),nods.end());
	for(int i=0;i<nods.size();i++){
		if(nods[i].x==1&&now==1)
			break;
		if(nods[i].x==1){
			now++;
		}
		if(nods[i].x==-1){
			now--;
			cnt++;
		}
	}
	cout<<cnt<<endl;
}
int main()
{
	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 129ms
memory: 5060kb

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
3
275
5575
10000

result:

wrong answer 2nd lines differ - expected: '1', found: '3'