47282023-03-31 10:14:46AblablablaÓvodacpp17Wrong answer 14/50103ms17068 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;


vector<int> siras;

bool comparefn(pii a, pii b){
    return a.first < b.first;
}

struct comp{
    bool operator()(int a, int b){
        return siras[a] > siras[b];
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> hely(k + 1, 0);
    for(int i = 1; i <= k; i++){
        cin >> hely[i];
    }

    vector<vector<int>> szerepre(k + 1, vector<int>());
    vector<int> akar(n + 1, 0);

    for(int i = 1; i <= n; i++){
        int a;
        cin >> a;
        szerepre[a].push_back(i);
        akar[i] = a;
    }

    siras.assign(n + 1, 0);
    for(int i = 1; i <= n; i++){
        cin >> siras[i];
    }

    int valasz = 0;
    vector<bool> sirniFog(n + 1, false);
    vector<pii> extrak(0, {0, 0});

    for(int i = 1; i <= k; i++){
        sort(szerepre[i].begin(), szerepre[i].end(), comp());
        for(int j = hely[i]; j < szerepre[i].size(); j++){
            int a = szerepre[i][j];
            valasz += siras[a];
            sirniFog[a] = true;
        }

        if(szerepre[i].size() < hely[i]){
            extrak.push_back({i, hely[i] - szerepre[i].size()});
        }
    }

    sort(extrak.begin(), extrak.end(), comparefn);
    /*for(pii akt : extrak){
        cout << akt.first << " " << akt.second << "\n";
    }*/

    /*for(int i = 1; i <= k; i++){
        cout << i << ":     ";
        for(int akt : szerepre[i]){
            cout << akt << " ";
        }

        cout << "\n";
    }

    for(int i = 1; i <= n; i++){
        cout << sirniFog[i] << "\n";
    }*/

    cout << valasz << "\n";
    return 0;

    int uresHely = 0;
    for(int i = 1; i <= n; i++){
        if(sirniFog[i]){
            cout << uresHely << " ";
            //uresErtek--;
        } else{
            cout << akar[i] << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Wrong answer0/03ms1812 KiB
2Wrong answer0/06ms2264 KiB
3Partially correct1/23ms2248 KiB
4Partially correct1/23ms2456 KiB
5Partially correct1/23ms2640 KiB
6Partially correct1/23ms2908 KiB
7Wrong answer0/23ms2904 KiB
8Partially correct1/22ms2972 KiB
9Partially correct1/22ms3100 KiB
10Partially correct1/23ms3308 KiB
11Partially correct1/23ms3396 KiB
12Partially correct1/23ms3612 KiB
13Wrong answer0/23ms3752 KiB
14Partially correct1/33ms3928 KiB
15Wrong answer0/312ms4960 KiB
16Wrong answer0/326ms6880 KiB
17Partially correct1/332ms5680 KiB
18Wrong answer0/357ms11064 KiB
19Partially correct1/356ms7244 KiB
20Partially correct1/359ms6848 KiB
21Partially correct1/374ms8596 KiB
22Wrong answer0/4103ms17068 KiB