46372023-03-30 13:31:59AblablablaÓvodacpp17Wrong answer 14/5093ms7260 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] + j < 0){
            valasz += szamok[j].second;
            j++;
            siros.push_back(j);
            //cout << i << " " << j << " " << valasz << " " << betolt[i] << " " << i << "\n";
        }
    }

    cout << valasz << "\n";
}
SubtaskSumTestVerdictTimeMemory
base14/50
1Wrong answer0/03ms1816 KiB
2Wrong answer0/06ms2228 KiB
3Partially correct1/23ms2212 KiB
4Partially correct1/22ms2424 KiB
5Partially correct1/23ms2640 KiB
6Partially correct1/22ms2752 KiB
7Wrong answer0/22ms2972 KiB
8Partially correct1/22ms3160 KiB
9Partially correct1/23ms3376 KiB
10Partially correct1/23ms3464 KiB
11Partially correct1/22ms3592 KiB
12Partially correct1/22ms3672 KiB
13Wrong answer0/23ms3808 KiB
14Partially correct1/33ms3892 KiB
15Wrong answer0/312ms4400 KiB
16Wrong answer0/325ms5000 KiB
17Partially correct1/335ms4948 KiB
18Wrong answer0/354ms5604 KiB
19Partially correct1/361ms5316 KiB
20Partially correct1/365ms5916 KiB
21Partially correct1/378ms5964 KiB
22Wrong answer0/493ms7260 KiB