QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#198367 | #6517. Computational Geometry | Linx | WA | 1ms | 8000kb | C++23 | 726b | 2023-10-03 13:24:21 | 2023-10-03 13:24:23 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int,int>
using namespace std;
int a[1000005],b[1000005],c[1000005];
void solve(){
int n,m;
scanf("%d%d",&n,&m);
ll ans=0;
for(int i=1;i<=n;i++){
scanf("%d%d",&a[i],&b[i]);
c[i]=b[i]-a[i];
ans+=a[i];
}
sort(c+1,c+n+1);
for(int i=n;i>2;i--){
if(c[i]>0&&m>=n+n-i+1){
ans+=c[i];
}
}
if(m>=n*2-1){
ll cnt=0;
for(int i=1;i<=n;i++){
cnt+=b[i];
}
ans=max(ans,cnt);
}
printf("%lld\n",ans);
}
int main(){
int t=1;
scanf("%d",&t);
while(t--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 8000kb
input:
2 4 1 0 2 0 1 1 0 0 6 10 4 9 7 5 7 4 5 6 4 9 3
output:
1 33
result:
wrong answer 1st numbers differ - expected: '4', found: '1'