acgo题库
  • 首页
  • 题库
  • 题单
  • 竞赛
  • 讨论
  • 排行
  • 团队
  • 备赛专区

    竞赛

    • CSP-J/S
    • 蓝桥杯

    考级

    • GESP
    • CPA
    • 电子学会考级
登录
注册
题目详情题解(0)讨论(0)提交记录(0)
  • 题解

    userId_undefined

    法兰西玫瑰

    倔强青铜
    65阅读
    0回复
    1点赞
  • 题解

    #include <iostream> #include <cmath> #include <string> #include <cstring> #include <iomanip> #include <algorithm> #include <vector> #include <cstdio> #define int long long using namespace std; /* 我们将原来白板上的和要替换的数放在一起,重新选前n大的数 但每次必须改变,最后一个需要替换的数是必须要在白板上的 此时我们将这前n大的数中最小的替换为这个数 如果这个数已经在前n大了,那就不需要了 */ const int N=1e5+3,M=2e5+3,inf=2147483647; int n,m,cnta,cntb; int a[N],b[N],c[M]; bool cmp(int a,int b){ return a>b; } signed main(){ scanf("%lld %lld",&n,&m); for(int i=1;i<=n;i++){ scanf("%lld",&a[i]); cnta+=a[i]; } for(int i=1;i<=m;i++)scanf("%lld",&b[i]); for(int i=1;i<=n;i++)c[i]=a[i]; for(int i=1;i<=m;i++)c[n+i]=b[i]; sort(c+1,c+1+n+m,cmp); for(int i=1;i<=n;i++)cntb+=c[i]; if(b[m]<c[n]){ cntb-=c[n]; cntb+=b[m]; } }

    userId_undefined

    小张张五

    AC狗饲养员
    倔强青铜
    58阅读
    0回复
    1点赞
  • 看来必须开long

    userId_undefined

    MuktorFM

    荣耀黄金
    10阅读
    0回复
    0点赞
首页