-
Notifications
You must be signed in to change notification settings - Fork 481
/
1089L.cpp
67 lines (63 loc) · 1.36 KB
/
1089L.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
//🎃🎃🎃😎😎😁🤓☣☣☣☣☣dark_coder☣☣☣☣☣😎😎😁🤓🎃🎃🎃
#include <bits/stdc++.h>
using namespace std;
#define IOS \
ios::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define li long long int
#define pi pair<int, int>
int main()
{
IOS li n, k;
cin >> n >> k;
li a[n], b[n];
for (li i = 0; i < n; i++)
{
cin >> a[i];
}
for (li i = 0; i < n; i++)
{
cin >> b[i];
}
li times[n], wwt[k] = {0};
for (li i = 0; i < n; i++)
{
if (wwt[a[i] - 1] == 0)
{
wwt[a[i] - 1] = b[i];
b[i] = INT_MAX;
}
else
{
if (wwt[a[i] - 1] < b[i])
swap(wwt[a[i] - 1], b[i]);
}
}
sort(b, b + n);
li ct = 0;
for (li i = 0; i < k; i++)
{
if (wwt[i] == 0)
ct++;
}
li sum = 0;
for (li i = 0; i < ct; i++)
{
sum += b[i];
}
// cout << ct << endl;
// for (int i = 0; i < k; i++)
// {
// cout << wwt[i] << " ";
// }
// cout << endl;
// for (int i = 0; i < n; i++)
// {
// cout << b[i] << " ";
// }
// cout << endl;
cout << sum;
return 0;
}