46332023-03-30 13:24:48ZsofiaKeresztelyÓvodacpp14Wrong answer 28/50108ms17576 KiB
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
#define fi first
#define se second

int main()
{
    int kids, roles;
    cin >> kids >> roles;
    vector<int> places(roles), pref(kids), op(kids, -1);
    vector<vector<pii> > cry(roles);
    for (int i=0; i<roles; i++){
        cin >> places[i];
    }
    for (int i=0; i<kids; i++){
        cin >> pref[i];
    }
    for (int i=0; i<kids; i++){
        int a;
        cin >> a;
        cry[pref[i]-1].push_back({a, i});
    }
    vector<pii> left;
    long long crysum = 0;
    for (int i=0; i<roles; i++){
        sort(cry[i].rbegin(), cry[i].rend());
        for (int j=0; j<min((int)cry[i].size(), places[i]); j++){
            op[cry[i][j].se] = i;
        }
        for (int j=min((int)cry[i].size(), places[i]); j<cry[i].size(); j++){
            crysum += cry[i][j].fi;
        }
        if (places[i] > cry[i].size()){
            left.push_back({places[i] - cry[i].size(), i});
        }
    }
    cout << crysum << "\n";
    int lind = 0;
    for (int i=0; i<kids; i++){
        if (op[i] < 0){
            op[i] = left[lind].se;
            left[lind].fi--;
            if (!left[lind].fi) lind++;
        }
        cout << op[i] + 1 << " ";
    }
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/03ms1844 KiB
2Wrong answer0/06ms2292 KiB
3Accepted2/22ms2092 KiB
4Partially correct1/23ms2212 KiB
5Accepted2/22ms2296 KiB
6Accepted2/23ms2700 KiB
7Wrong answer0/23ms2756 KiB
8Partially correct1/23ms2772 KiB
9Accepted2/23ms3032 KiB
10Accepted2/23ms3180 KiB
11Accepted2/22ms3256 KiB
12Partially correct1/23ms3344 KiB
13Wrong answer0/23ms3776 KiB
14Accepted3/33ms3816 KiB
15Wrong answer0/313ms4960 KiB
16Wrong answer0/328ms6904 KiB
17Accepted3/335ms5976 KiB
18Wrong answer0/363ms11004 KiB
19Accepted3/364ms8188 KiB
20Accepted3/370ms8320 KiB
21Partially correct1/385ms9848 KiB
22Wrong answer0/4108ms17576 KiB