QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#141283 | #6525. New Houses | cy1999 | WA | 1ms | 3624kb | C++11 | 697b | 2023-08-17 10:15:04 | 2023-08-17 10:15:07 |
Judging History
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'