这么贪心有什么不对吗?
查看原帖
这么贪心有什么不对吗?
1122530
elpsconr楼主2024/10/21 13:20

wa能理解,我不理解为什么RE了

/*
   卫风·芄兰
芄兰之支,童子佩觿.
虽则佩觿,能不我知?
容兮遂兮,垂带悸兮.
芄兰之叶,童子佩韘.
虽则佩韘,能不我甲?
容兮遂兮,垂带悸兮.
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PII pair<int,int>
#define tul tuple<int,int,int>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define rep_(i,a,b) for(int i=a;i>=b;--i)
#define all(x) x.begin(),x.end()
#define bp(x) __builtin_popcountll(x)
#define cy cout<<"YES"<<endl
#define cn cout<<"NO"<<endl
#define lc (rt<<1)
#define rc (rt<<1|1)
mt19937_64 rnd(time(0));
const int N=3e5+5,yyx=998244353;
vector<int> to[N],t;
int n,k;
inline int mod(int x){
  return (x%yyx+yyx)%yyx;
}
inline int cmin(int &x,int y){
  return x>y?x=y,1:0;
}
inline int cmax(int &x,int y){
  return x<y?x=y,1:0;
}
struct node{
    int a,b,c;
    bool operator< (node w){
        return c<=w.c;
    }
}e[N];
inline void solve(){
  cin>>n>>k;
  rep(i,1,n) cin>>e[i].a;
  rep(i,1,n) cin>>e[i].b,e[i].c=e[i].a*e[i].b;
  sort(e+1,e+1+n);
  int ma=0;
  int ans=0;
  rep(i,1,k){
    auto [a,b,c]=e[i];
    ma=max(ma,a);
    ans+=b;
  }
  ans*=ma;
  cout<<ans<<endl;
}
signed main(){
  cin.tie(0)->sync_with_stdio(0);
  //freopen("D://321//in.txt","r",stdin);
  //freopen("D://321//out.txt","w",stdout);
  int _=1;
  cin>>_;
  while(_--)
  solve();
  return 0;
}
2024/10/21 13:20
加载中...