-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
39 lines (36 loc) · 735 Bytes
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include<bits/stdc++.h>
using namespace std;
#define fastio ios::sync_with_stdio(0);cin.tie(0)
long long ara[300005],b[300005];
int main()
{
fastio;
long long t,n,i,suma,sumb,mna,mnb;
cin>>t;
while(t--)
{
cin>>n;
suma=0;
sumb=0;
for(i=0;i<n;i++)
{
cin>>ara[i];
suma+=ara[i];
if(i==0)
mna=ara[i];
else
mna=min(mna,ara[i]);
}
for(i=0;i<n;i++)
{
cin>>b[i];
sumb+=b[i];
if(i==0)
mnb=b[i];
else
mnb=min(mnb,b[i]);
}
cout<<min(n*mna+sumb,n*mnb+suma)<<"\n";
}
return 0;
}