QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#198368#6517. Computational GeometryLinxRE 0ms0kbC++23745b2023-10-03 13:24:482023-10-03 13:24:49

Judging History

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

  • [2023-10-03 13:24:49]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2023-10-03 13:24:48]
  • 提交

answer

#include<bits/stdc++.h>
#define int ll
#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);
}
signed main(){
    int t=1;
    scanf("%d",&t);
    while(t--)solve();
    return 0;
}

詳細信息

Test #1:

score: 0
Runtime Error

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:


result: