47262023-03-31 10:04:17Albertstein99Óvodacpp17Wrong answer 28/50112ms23592 KiB
#include <bits/stdc++.h>
using namespace std;

typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;

int main(){
    int N, K;
    cin >> N >> K;
    vector <int> M(K + 1);
    for(int i = 1; i <= K; i++)
        cin >> M[i];
    vector <int> S(N + 1);
    for(int i = 1; i <= N;i++)
        cin >> S[i];
    vector <int> T(N + 1);
    for(int i = 1; i <= N;i++)
        cin >> T[i];
    vvpii R(K + 1);
    for(int i = 1; i <= N; i++)
        R[S[i]].push_back({T[i], i});
    for(auto &x : R)
        sort(x.begin(), x.end());
    vector <int> extras;
    for(int i = 1; i <= K; i++)
        for(int j = R[i].size(); j < M[i]; j++)
            extras.push_back(i);
    vector <int> P(N + 1);
    int x = 0;
    for(int i = 1; i <= K; i++){
        int num = max((signed long long)(R[i].size() - M[i]), 0ll);
        for(int j = 0; j < num; j++)
            P[R[i][j].second] = extras[x++];
        for(int j =  num; j < R[i].size(); j++)
            P[R[i][j].second] = i;
    }
    int cry = 0;
    for(int i = 1; i <= N; i++){
        if(S[i] != P[i])
            cry += T[i];
    }
    cout << cry << "\n";
    for(int i = 1; i <= N; i++)
        cout << P[i] << " ";
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1812 KiB
2Wrong answer0/06ms2516 KiB
3Accepted2/23ms2212 KiB
4Partially correct1/22ms2464 KiB
5Accepted2/22ms2640 KiB
6Accepted2/22ms2852 KiB
7Wrong answer0/23ms3092 KiB
8Partially correct1/23ms3304 KiB
9Accepted2/23ms3520 KiB
10Accepted2/22ms3636 KiB
11Accepted2/22ms3608 KiB
12Partially correct1/23ms3688 KiB
13Wrong answer0/23ms3744 KiB
14Accepted3/33ms3716 KiB
15Wrong answer0/313ms4900 KiB
16Wrong answer0/328ms7168 KiB
17Accepted3/337ms7528 KiB
18Wrong answer0/365ms14200 KiB
19Accepted3/365ms9128 KiB
20Accepted3/371ms9340 KiB
21Partially correct1/385ms10560 KiB
22Wrong answer0/4112ms23592 KiB