58162023-10-02 17:41:42lacitoVállalkozócpp17Accepted 40/4032ms4764 KiB
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m;
	cin >> n >> m;
	vector<int> napok(n);
    vector<int> hataridok(m);
    for(int i = 0; i < n; i++) 
        cin >> napok[i];
        
        
    for(int i = 0; i < m; i++) 
        cin >> hataridok[i];

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

    
    int j = 0; // hataridok index, hanyadik munka
    int out = 0;
    for (int i = 0; i < n; i++) {
        while (j < m && napok[i]) {
            // cerr << i + 1 << " " << napok[i] << " " << j << " " << hataridok[j] << endl;
            if (hataridok[j] >= i+1) {
                out++;
                napok[i]--;
                j++;
            } else {
                j++;
            }
        }
    }
    cout << out;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1816 KiB
2Accepted0/032ms2760 KiB
3Accepted2/23ms2284 KiB
4Accepted2/22ms2296 KiB
5Accepted2/23ms2548 KiB
6Accepted2/23ms2700 KiB
7Accepted2/24ms2772 KiB
8Accepted2/23ms2768 KiB
9Accepted2/24ms2916 KiB
10Accepted2/23ms3028 KiB
11Accepted2/23ms3040 KiB
12Accepted2/24ms3168 KiB
13Accepted2/24ms3264 KiB
14Accepted2/24ms3256 KiB
15Accepted2/210ms3608 KiB
16Accepted2/210ms3792 KiB
17Accepted2/214ms3812 KiB
18Accepted2/210ms3900 KiB
19Accepted2/213ms4048 KiB
20Accepted2/217ms4036 KiB
21Accepted2/224ms4292 KiB
22Accepted2/232ms4764 KiB