QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#196275#6895. a-b ProblemRoyo#WA 72ms5068kbC++20614b2023-10-01 14:58:102023-10-01 14:58:11

Judging History

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

  • [2023-10-01 14:58:11]
  • 评测
  • 测评结果:WA
  • 用时:72ms
  • 内存:5068kb
  • [2023-10-01 14:58:10]
  • 提交

answer

#include<bits/stdc++.h>

using namespace std;

const int N=1e5+10;

struct Node{
	int sum;
	int a,b;
} node[N];
int n,t;

bool cmp(Node x,Node y)
{
	return x.sum>y.sum;
}

int main()
{
	cin>>t;
	while(t--)
	{
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&node[i].a,&node[i].b);
			node[i].sum=node[i].a+node[i].b;
		} 
		sort(node+1,node+1+n,cmp);
		long long ans=0;
		int flag=1;
		for(int i=n;i>=1;i--)
		{
			if(flag==1)
			{
				ans+=node[i].a;
			}
			else 
			{
				ans-=node[i].b;
			}
			flag*=-1;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 72ms
memory: 5068kb

input:

20
3
0 2
1 2
3 3
3
1 0
2 3
0 4
4
2 8
1 14
10 2
10 6
2
1 3
3 4
2
4 8
6 2
2
0 0
10 10
2
5 0
2 1
2
4 5
6 2
3
4 2
10 9
3 8
3
6 1
3 4
4 0
3
10 3
7 3
2 10
3
1 9
8 1
0 0
4
1 2
15 8
11 8
10 2
4
9 3
5 14
10 5
2 12
4
7 6
7 6
12 11
2 15
100000
3 1
10 8
1 8
7 9
3 6
9 2
0 7
1 3
7 1
2 0
10 9
2 5
0 3
6 1
9 0
1 1
1...

output:

1
-1
-5
-3
-2
-10
2
1
6
6
7
0
2
-7
-8
-708
-24973085279109
24978140601872
41095353522
-62281404535

result:

wrong answer 3rd lines differ - expected: '-2', found: '-5'