46342023-03-30 13:28:00AblablablaÓvodacpp17Wrong answer 6/5093ms13796 KiB
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;

struct comp{
    bool operator()(pii a, pii b){
        if(a.first < b.first){
            return true;
        } else if(a.first > b.first){
            return false;
        } else{
            return a.second < b.second;
        }
    }
};

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> maxi(k + 1, 0);
    for(int i = 1; i <= k; i++){
        cin >> maxi[i];
    }
    vector<int> betolt(k + 1, 0);
    vector<pii> szamok(n, {0, 0});  //i edik par elso eleme a kivant szerep masodik a sirassal toltott percek
    for(int i = 0; i < n; i++){
        cin >> szamok[i].first;
        betolt[szamok[i].first]++;
    }

    for(int i = 1; i <= k; i++){
        betolt[i] += betolt[i - 1];
    }

    for(int i = 0; i < n; i++){
        cin >> szamok[i].second;
    }

    sort(szamok.begin(), szamok.end(), comp());

    for(pii x : szamok){
        //cout << x.first << " " << x.second << "\n";
    }

    for(int x : betolt){
        //cout << x << "\n";
    }

    int valasz = 0;
    vector<int> siros;

    for(int i = 1; i <= k; i++){
        int j = betolt[i - 1];
        //cout << i << " " << maxi[i] - betolt[i] << "\n";
        while(maxi[i] - (betolt[i] - betolt[i - 1]) < 0){
            valasz += szamok[j].second;
            j++;
            betolt[i]--;
            siros.push_back(j);
            //cout << i << " " << j << " " << valasz << " " << betolt[i] << " " << i << "\n";
        }
    }

    cout << valasz << "\n";
}
SubtaskSumTestVerdictTimeMemory
base6/50
1Wrong answer0/03ms1684 KiB
2Wrong answer0/06ms2020 KiB
3Wrong answer0/23ms2064 KiB
4Partially correct1/23ms2300 KiB
5Wrong answer0/22ms2388 KiB
6Partially correct1/23ms2600 KiB
7Wrong answer0/23ms2692 KiB
8Partially correct1/23ms2944 KiB
9Partially correct1/23ms3024 KiB
10Wrong answer0/23ms3152 KiB
11Partially correct1/22ms3244 KiB
12Wrong answer0/23ms3364 KiB
13Wrong answer0/23ms3596 KiB
14Wrong answer0/33ms3708 KiB
15Wrong answer0/312ms3964 KiB
16Wrong answer0/326ms5244 KiB
17Partially correct1/334ms4704 KiB
18Wrong answer0/354ms5380 KiB
19Wrong answer0/359ms5260 KiB
20Wrong answer0/370ms13796 KiB
21Wrong answer0/378ms6368 KiB
22Wrong answer0/493ms7204 KiB