forked from shauryas1ngh/codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCHPINTU.cp
More file actions
54 lines (39 loc) · 924 Bytes
/
CHPINTU.cp
File metadata and controls
54 lines (39 loc) · 924 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
using namespace std;
#include<iostream>
int main()
{
int t;
cin>>t;
while(t--)
{
int m, n;
cin>>n>>m;
int f[n], p[n];
for(int i=0;i<n;i++)
cin>>f[i];
for(int i=0;i<n;i++)
cin>>p[i];
int tp[m];
for(int i=0;i<m;i++)
tp[i]=0;
for(int i=0;i<n;i++)
{
tp[f[i]-1]=tp[f[i]-1]+p[i];
}
for(int i=0;i<m;i++)
cout<<tp[i]<<" ";
cout<<endl;
int min1=60000000;
for(int i=0;i<m;i++)
{
int test=-1;
for(int j=0;j<n;j++)
if(f[j]==i+1)
test=1;
if(test==1 && tp[i]<min1)
min1=tp[i];
}
cout<<min1<<endl;
}
return 0;
}