-
Notifications
You must be signed in to change notification settings - Fork 0
/
lazyland.cpp
72 lines (71 loc) · 2.08 KB
/
lazyland.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
#include<bits/stdc++.h>
//#define time clock_t tStart = clock();
#define show printf("Time taken: %.6fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
#define ll long long int
#define loop(a,b) for(int i=a;i<=b;++i)
#define count_1(n) __builtin_popcountll(n)
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define MOD 1000000007
#define itoc(c) ((char)(((int)'0')+c))
#define vi vector<int>
#define vll vector<ll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define all(p) p.begin(),p.end()
#define mid(s,e) (s+(e-s)/2)
#define tcase() ll t,n; cin>>t;n=t; while(t--)
#define iscn(num) scanf("%d",&num);
#define eb emplace_back
#define ull unsigned long long
#define KAMEHAMEHA ios_base::sync_with_stdio(0);
#define RASENGAN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
bool jobs[100050];
int main()
{
KAMEHAMEHA
// #ifdef _soumik
// freopen("input.txt", "r", stdin);
// #endif
ll n,k,done=0;
cin>>n>>k;
vi lazy(n+50),people;
vector < pii > time;
for(ll i=1;i<=n;i++)
{
ll temp;
cin>>temp;
lazy[temp]++;
people.eb(temp);
if(!jobs[temp])
{
done++;
jobs[temp]=true;
}
}
int left=k-done;
for(ll i=1,temp;i<=n;i++)
{
cin>>temp;
time.eb(temp,i);
}
ll total=0;
sort(all(time));
for(ll i=0;i<n;i++)
{
if(left==0)
break;
if(lazy[people[time[i].S-1]]>1)
{
//cout<<time[i].F<< " "<<time[i].S<<endl;
lazy[people[time[i].S-1]]--;
total+=time[i].F;
left--;
}
}
cout<<total<<endl;
return 0;
}