150722025-02-12 11:17:44mateÓvodacpp17Wrong answer 28/50105ms4780 KiB
#include <bits/stdc++.h>
using namespace std;

#define p array<int,3>
#define int long long

signed main() {
	int n,k; cin >> n >> k;
    vector <int> v(k+1);
    for(int i = 1; i <= k; i++){
        cin >> v[i];
    }
    vector <p> emberek(n+1,{0,0,0});
    for(int i = 1; i <= n; i++){
        cin >> emberek[i][1];
        emberek[i][2] = i;
    }
    for(int i = 1; i <= n; i++){
        cin >> emberek[i][0];
    }
    sort(emberek.begin(),emberek.end());
    int cnt = 0;
    vector <int> ans(n+1,0);
    for(int i = n; i > 0; i--){
        if(v[emberek[i][1]] > 0)   {
            v[emberek[i][1]]--;
            ans[emberek[i][2]] = emberek[i][1];
        }else{
            cnt += emberek[i][0];
        }
    }
    cout << cnt << '\n';
    bool kesz = 0;
    for(int& x : ans){
        if(!kesz){
            kesz = 1;
            continue;
        }
        if(x == 0){
            for(int i = 1; i <= k; i++){
                if(v[i] > 0){
                    x = i;
                    v[i]--;
                    break;
                }
            }
        }
        cout << x << ' ';
    }
}
SubtaskSumTestVerdictTimeMemory
base28/50
1Accepted0/01ms316 KiB
2Wrong answer0/04ms564 KiB
3Accepted2/21ms316 KiB
4Partially correct1/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Wrong answer0/21ms316 KiB
8Partially correct1/21ms500 KiB
9Accepted2/21ms316 KiB
10Accepted2/21ms316 KiB
11Accepted2/21ms316 KiB
12Partially correct1/21ms316 KiB
13Wrong answer0/22ms316 KiB
14Accepted3/32ms316 KiB
15Wrong answer0/312ms856 KiB
16Wrong answer0/346ms1456 KiB
17Accepted3/339ms2020 KiB
18Wrong answer0/363ms2964 KiB
19Accepted3/371ms3416 KiB
20Accepted3/379ms3636 KiB
21Partially correct1/397ms4148 KiB
22Wrong answer0/4105ms4780 KiB