47132023-03-31 09:51:57AblablablaÓvodacpp17Wrong answer 14/5093ms14292 KiB
#include <bits/stdc++.h>

using namespace std;

typedef pair<int, int> pii;


vector<int> siras;

struct comp{
    bool operator()(int a, int b){
        if(siras[a] == siras[b]){
            return a > 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>(0, 0));
    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);

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

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

    int uresHely = 0;
    int uresErtek = 0;
    for(int i = 1; i <= n; i++){
        if(sirniFog[i]){
            if(uresErtek == 0){
                while(szerepre[uresHely].size() >= hely[uresHely]){
                    uresHely++;
                }
                uresErtek = hely[uresHely] - szerepre[uresHely].size();
            }

            cout << uresHely << " ";
            uresErtek--;
        } else{
            cout << akar[i] << " ";
        }
    }
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Wrong answer0/03ms1808 KiB
2Wrong answer0/06ms2308 KiB
3Partially correct1/23ms2212 KiB
4Partially correct1/23ms2432 KiB
5Partially correct1/23ms2640 KiB
6Partially correct1/22ms2720 KiB
7Wrong answer0/23ms2880 KiB
8Partially correct1/23ms2872 KiB
9Partially correct1/22ms2876 KiB
10Partially correct1/23ms3028 KiB
11Partially correct1/23ms3152 KiB
12Partially correct1/23ms3236 KiB
13Wrong answer0/23ms3380 KiB
14Partially correct1/33ms3316 KiB
15Wrong answer0/312ms3996 KiB
16Wrong answer0/325ms5720 KiB
17Partially correct1/330ms4696 KiB
18Wrong answer0/354ms8856 KiB
19Partially correct1/354ms6088 KiB
20Partially correct1/359ms6084 KiB
21Partially correct1/371ms7252 KiB
22Wrong answer0/493ms14292 KiB