58322023-10-03 17:11:21CzDaniVállalkozócpp14Accepted 40/4034ms5080 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> m >> n;
	vector<int> v(n+1), w(m+1);
	for (int i = 1; i <= m; i++) {
		cin >> w[i];
	}
	for (int i = 1; i <= n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	int ans = 0, l = 1;
	for (int i = 1; i <= m; i++) {
		while(l<=n&&v[l] < i) l++;
		while(w[i]>0&&l<=n) {
			ans++;
			l++;
			w[i]--;
		}
	}
	cout << ans;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1808 KiB
2Accepted0/034ms2704 KiB
3Accepted2/22ms2124 KiB
4Accepted2/22ms2320 KiB
5Accepted2/23ms2532 KiB
6Accepted2/24ms2748 KiB
7Accepted2/24ms3124 KiB
8Accepted2/23ms3204 KiB
9Accepted2/24ms3236 KiB
10Accepted2/23ms3220 KiB
11Accepted2/24ms3364 KiB
12Accepted2/24ms3336 KiB
13Accepted2/24ms3480 KiB
14Accepted2/24ms3676 KiB
15Accepted2/210ms3992 KiB
16Accepted2/212ms4112 KiB
17Accepted2/216ms4284 KiB
18Accepted2/210ms4516 KiB
19Accepted2/213ms4792 KiB
20Accepted2/217ms4672 KiB
21Accepted2/225ms4692 KiB
22Accepted2/234ms5080 KiB