58152023-10-02 17:40:50lacitoVállalkozócpp17Time limit exceeded 24/40200ms3704 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
base24/40
1Accepted0/03ms1812 KiB
2Time limit exceeded0/0200ms1640 KiB
3Accepted2/23ms2276 KiB
4Accepted2/23ms2492 KiB
5Accepted2/23ms2720 KiB
6Accepted2/235ms2936 KiB
7Accepted2/265ms2988 KiB
8Accepted2/232ms3072 KiB
9Accepted2/296ms3212 KiB
10Accepted2/225ms3212 KiB
11Accepted2/264ms3260 KiB
12Accepted2/265ms3240 KiB
13Accepted2/2103ms3508 KiB
14Accepted2/283ms3576 KiB
15Time limit exceeded0/2173ms2936 KiB
16Time limit exceeded0/2157ms2960 KiB
17Time limit exceeded0/2177ms3072 KiB
18Time limit exceeded0/2165ms3092 KiB
19Time limit exceeded0/2172ms3152 KiB
20Time limit exceeded0/2181ms3084 KiB
21Time limit exceeded0/2160ms3344 KiB
22Time limit exceeded0/2158ms3704 KiB