#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n>>k;
int a[n];
int b[n];
for(int i=0;i<n;i++)
cin>>a[i];
for(int i=0;i<n;i++)
cin>>b[i];
int c[n];
c[0]=b[0];
for(int i=1;i<n;i++)
{
c[i]=max(c[i-1],b[i]);
}
int t=0;
int ans=0;
int sum=0;
for(int i=0;i<min(k,n);i++)
{
int c1=0;
int j=0;
//for( j=0;j<=min(i,k);j++)
{ sum+=a[i];
}
//cout<<j<<" ";
c1=(k-i-1)*c[i];
ans=max(c1+sum,ans);
}
cout<<ans<<endl;
}
}
32. Longest Valid Parentheses | Cutting a material |
Bubble Sort | Number of triangles |
AND path in a binary tree | Factorial equations |
Removal of vertices | Happy segments |
Cyclic shifts | Zoos |
Build a graph | Almost correct bracket sequence |
Count of integers | Differences of the permutations |
Doctor's Secret | Back to School |
I am Easy | Teddy and Tweety |
Partitioning binary strings | Special sets |
Smallest chosen word | Going to office |
Color the boxes | Missing numbers |
Maximum sum | 13 Reasons Why |
Friend's Relationship | Health of a person |
Divisibility | A. Movement |