-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy path1.cpp
More file actions
33 lines (33 loc) · 835 Bytes
/
1.cpp
File metadata and controls
33 lines (33 loc) · 835 Bytes
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
#include<bits/stdc++.h>
using namespace std;
int main(){
int t; cin>>t;
while(t--){
int n,m;
cin>>n>>m;
int f[n];
int p[n];
for(int i=0;i<n;i++)
cin>>f[i];
for(int i=0;i<n;i++)
cin>>p[i];
int HashArray[m+1];
for(int i=0;i<m+1;i++)
HashArray[i] = -1;
for(int i=0;i<n;i++){
if(HashArray[f[i]] == -1)
HashArray[f[i]] = 0;
HashArray[f[i]] += p[i];
}
int minprice = 10000;
for(int i=0;i<m+1;i++){
if(HashArray[i]<minprice && HashArray[i] != -1){
minprice = HashArray[i];
}
}
if(minprice == 10000)
minprice = 0;
cout<<minprice<<endl;
}
return 0;
}