58342023-10-03 17:20:19hello123Vállalkozócpp14Accepted 40/4035ms5028 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/03ms1808 KiB
2Accepted0/035ms2760 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2460 KiB
5Accepted2/22ms2544 KiB
6Accepted2/24ms2920 KiB
7Accepted2/24ms2936 KiB
8Accepted2/23ms3412 KiB
9Accepted2/24ms3436 KiB
10Accepted2/23ms3504 KiB
11Accepted2/24ms3712 KiB
12Accepted2/24ms3472 KiB
13Accepted2/24ms3536 KiB
14Accepted2/24ms3692 KiB
15Accepted2/210ms4004 KiB
16Accepted2/210ms3792 KiB
17Accepted2/216ms3988 KiB
18Accepted2/210ms4028 KiB
19Accepted2/214ms4308 KiB
20Accepted2/217ms4428 KiB
21Accepted2/224ms4512 KiB
22Accepted2/234ms5028 KiB