forked from shrutigoyal910/Hff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCHPINTU.cpp
80 lines (68 loc) · 1.51 KB
/
CHPINTU.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include<cstdlib>
#include<iostream>
#include<vector>
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
int main()
{
int t;
cin>>t;
int n,m,x=0,w=0;
vector <int> v;
vector<int>u;
while(t--)
{
scanf("%d %d",&n,&m);
//scanf("%d",&m);
vector <int>ans;
int temp=n;
if(m>=1&&n>=1&&m<=50&&n<=50)
{
while(temp--)
{
scanf("%d",&x);
v.push_back(x);
}
temp=n;
x=0;
while(temp--)
{
scanf("%d",&x);
u.push_back(x);
}
x=0;
for(int j=1;j<=m;j++)
{
for(int i=0;i<n;i++)
{
if(v[i]==j)
{
x=u[i]+x;
}
else
{
continue;
}
}
ans.push_back(x);
x=0;
}
sort(ans.begin(),ans.end());
int z=m;
for(int i=0;i<m;i++)
{
if(ans[i]!=0)
{
printf("%d",ans[i]);
break;
}
else
{
continue;
}
}
}
}
return 0;
}