For this Question: Harry saved money to have a dinner at a five star restaurant. He want to have a complete meal. The restaurant has N items on it's menu. The menu's i<sup>th</sup> item belongs to the category A<sub>i</sub> and takes B<sub>i</sub> time to prepare. His dinner meal should include at least K different categories of food. The sum of the cooking times for each item in Harry's order is the total time needed to prepare everything he orders. Find the minimum time Harry needs to have a complete meal for himself or or let him know if it is not possible to do so.First line will contain T, the number of test cases. Then the test cases follow. Each test case contains three lines:<ul><li>The first line of each test case contains two space- separated integers N and K, denoting the number of dishes on the menu and the number of distinct categories in a complete meal. </li><li>The second line contains N space- separated integers where the i<sup>th</sup> integer is A<sub>i</sub>, denoting the category of the i<sup>th</sup>dish in the menu. </li><li>The third line contains N space- separated integers where the i<sup>th</sup>integer is B<sub>i</sub>, denoting the time required to cook the i<sup>th</sup> dish in the menu. </li></ul>

<b>Constraints</b>
1 &le; T &le; 100
1 &le; N, K &le; 10<sup>5</sup>
1 &le; A<sub>i</sub> &le; 10<sup>5</sup>
0 &le; B<sub>i</sub> &le; 10<sup>5</sup>
The sum of N over all test cases won't exceed 10<sup>5</sup>.For each test case, output in a single line, the minimum time required to have a complete meal. If it is impossible to have a complete meal, print -1 instead.Sample Input :
4
3 1
1 2 3
2 1 3
8 3
1 3 2 2 4 1 3 5
3 3 0 1 2 4 1 4
1 1
5
1
5 3
1 1 2 2 1
1 1 0 3 5
Sample Output :
1
3
1
-1
Explanation :
<ul><li>Harry can choose dish with index 2 having category 2. The total time required to get the complete meal is 1. </li><li>Harry can choose dishes with index 3, 5, and 7 from the menu. <ul><li>Dish 3: The dish has category 2 and requires time 0. </li><li>Dish 5: The dish has category 4 and requires time 2. </li><li>Dish 7: The dish has category 3 and requires time 1. </li></ul>Thus, there are 3 distinct categories and the total time to get the meal is 0 + 2 + 1 = 3. It can be shown that this is the minimum time to get the complete meal. </li><li>Harry can choose the only available dish having category 5. The total time required to get the complete meal is 1. </li><li>The total number of distinct categories available is 2, which is less than K. Thus, it is impossible to have a complete meal. </li></ul>, I have written this Solution Code: #include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#define ax long long

using namespace std;

void solve(){
    ax cv,q;
    cin>>cv>>q;
    vector<ax>a(cv),b(cv);
    set<ax>unq;
    ax e = 0;
    while (e < cv) {
        cin>>a[e];
        unq.insert(a[e]);
        e++;
    }
    e = 0;
    while (e < cv) {
        cin>>b[e];
        e++;
    }
    if (unq.size()<q)
    {
        cout<<-1<<endl;
        return;
    }
    map<ax, ax>re;
    e = 0;
    while (e < cv) {
        if (re.find(a[e])==re.end())
        {
            re[a[e]]=b[e];
        } else {
            re[a[e]]=min(re[a[e]],b[e]);
        }
        e++;
    }
    vector<ax>oi;
    for(auto&x:re)oi.push_back(x.second);
    sort(oi.begin(), oi.end());
    ax ans=accumulate(oi.begin(),oi.begin()+q,0LL);
    cout<<ans<<endl;

}

int main(){
    ax t=1;
    cin>>t;
    while(t--){
        solve();
    }
}, In this Programming Language: C++, Now tell me if this Code is compilable or not?