47092023-03-31 09:49:16AblablablaÓvodacpp17Wrong answer 21/50108ms14844 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";

    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
base21/50
1Accepted0/03ms1816 KiB
2Wrong answer0/06ms2252 KiB
3Accepted2/23ms2112 KiB
4Partially correct1/23ms2188 KiB
5Partially correct1/23ms2328 KiB
6Accepted2/23ms2544 KiB
7Wrong answer0/23ms2812 KiB
8Partially correct1/23ms2856 KiB
9Accepted2/23ms2936 KiB
10Accepted2/23ms2908 KiB
11Accepted2/23ms3032 KiB
12Partially correct1/23ms3372 KiB
13Wrong answer0/23ms3696 KiB
14Partially correct1/33ms3564 KiB
15Wrong answer0/314ms4504 KiB
16Wrong answer0/328ms6148 KiB
17Accepted3/337ms5148 KiB
18Wrong answer0/364ms9264 KiB
19Partially correct1/365ms6536 KiB
20Partially correct1/371ms6556 KiB
21Partially correct1/386ms7736 KiB
22Wrong answer0/4108ms14844 KiB