QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141283#6525. New Housescy1999WA 1ms3624kbC++11697b2023-08-17 10:15:042023-08-17 10:15:07

Judging History

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

  • [2023-08-17 10:15:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3624kb
  • [2023-08-17 10:15:04]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=5e5+5;
int t,n,m;
int sum[N];
struct node
{
	int a,b,z;
}w[N];
bool cmp(node x,node y)
{
	return x.z>y.z;
}
signed main()
{
	cin>>t;
	while(t--)
	{
		int num=0;
		cin>>n>>m;
		for(int i=1;i<=n;i++)
		{
			cin>>w[i].a>>w[i].b;
			num+=w[i].b;
			w[i].z=w[i].a-w[i].b;
		}
		sort(w+1,w+n+1,cmp);
		int maxn=num;
		//cout<<"@@@"<<endl;
		for(int i=1;i<=n;i++)
		{
		//	cout<<w[i].z<<"  ";
			sum[i]=sum[i-1]+w[i].z;
		}
		for(int x=2;x<=n;x++)
		{
			if(( (m-x)/2 )<n-x)
			{
				continue;
			}
			maxn=max(maxn,num+sum[x]);
		//	cout<<666<<endl;
		}
		cout<<maxn<<endl;
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3624kb

input:

3
4 5
1 100
100 1
100 1
100 1
2 2
1 10
1 10
2 3
100 50
1 1000

output:

400
20
1050

result:

wrong answer 2nd numbers differ - expected: '2', found: '20'