46292023-03-30 13:08:47ZsofiaKeresztelyÓvodacpp14Wrong answer 28/50109ms17100 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;
    int 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/03ms1680 KiB
2Wrong answer0/07ms2216 KiB
3Accepted2/23ms2140 KiB
4Partially correct1/23ms2356 KiB
5Accepted2/23ms2604 KiB
6Accepted2/23ms2808 KiB
7Wrong answer0/22ms2864 KiB
8Partially correct1/22ms2784 KiB
9Accepted2/23ms2908 KiB
10Accepted2/22ms3020 KiB
11Accepted2/22ms3028 KiB
12Partially correct1/23ms3152 KiB
13Wrong answer0/23ms3284 KiB
14Accepted3/33ms3228 KiB
15Wrong answer0/314ms4284 KiB
16Wrong answer0/328ms6448 KiB
17Accepted3/337ms5792 KiB
18Wrong answer0/363ms10628 KiB
19Accepted3/365ms7816 KiB
20Accepted3/371ms7964 KiB
21Partially correct1/386ms9632 KiB
22Wrong answer0/4109ms17100 KiB