58402023-10-03 17:58:04neszbalVállalkozócpp17Accepted 40/4059ms5068 KiB
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int N, M, rendelesek = 0;
    cin >> N >> M;

    vector<int> munkaora(N);
    vector<int> hatarido(M);

    for (int i = 0; i < N; i++) {
        cin >> munkaora[i];
    }

    for (int i = 0; i < M; i++) {
        cin >> hatarido[i];
    }

    sort(hatarido.begin(), hatarido.end());


    /*
    3 5
    2 0 6
    1
    2
    2
    3
    3
    
    
    */




    for(int i = 0; i < N; i++){
        int munka = munkaora[i];
        if(munka == 0) continue;

        for(int j = 0; j < M; j++) {
            if(hatarido[j] >= i+1 && munka > 0 && hatarido[j] != -1) {
                rendelesek++;
                munka--;
                hatarido[j] = -1;
            }
            if(munka == 0) break;
        }
       
    }


    
    cout << rendelesek;


    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1684 KiB
2Accepted0/059ms2756 KiB
3Accepted2/23ms2144 KiB
4Accepted2/23ms2360 KiB
5Accepted2/23ms2572 KiB
6Accepted2/24ms2748 KiB
7Accepted2/24ms2940 KiB
8Accepted2/23ms3148 KiB
9Accepted2/24ms3376 KiB
10Accepted2/23ms3408 KiB
11Accepted2/24ms3552 KiB
12Accepted2/24ms3564 KiB
13Accepted2/24ms3672 KiB
14Accepted2/24ms3788 KiB
15Accepted2/212ms3872 KiB
16Accepted2/213ms4004 KiB
17Accepted2/239ms4004 KiB
18Accepted2/235ms4240 KiB
19Accepted2/237ms4392 KiB
20Accepted2/229ms4300 KiB
21Accepted2/241ms4344 KiB
22Accepted2/257ms5068 KiB