61732023-11-05 12:39:58xxxVállalkozócpp14Accepted 40/4034ms5156 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> b[i];
	}

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

	int j = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		while(j < m && a[i] > 0) {
			if (b[j] >= i+1) {
				j++;
				ans++;
				a[i]--;
			} else {
				j++;
			}
		}
	}

	cout << ans << "\n";
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/034ms2756 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2324 KiB
5Accepted2/23ms2528 KiB
6Accepted2/24ms2788 KiB
7Accepted2/24ms3004 KiB
8Accepted2/23ms3184 KiB
9Accepted2/24ms3408 KiB
10Accepted2/23ms3592 KiB
11Accepted2/24ms3712 KiB
12Accepted2/23ms3940 KiB
13Accepted2/24ms4088 KiB
14Accepted2/24ms4160 KiB
15Accepted2/210ms4408 KiB
16Accepted2/212ms4400 KiB
17Accepted2/216ms4428 KiB
18Accepted2/212ms4536 KiB
19Accepted2/214ms4688 KiB
20Accepted2/217ms4468 KiB
21Accepted2/224ms4556 KiB
22Accepted2/234ms5156 KiB