58922023-10-04 18:24:07MorvaiVarkonyVállalkozócpp11Accepted 40/4034ms5504 KiB
// Source: https://usaco.guide/general/io

#include <bits/stdc++.h>
using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector<int> v;
	for (int i=0; i<n; i++) {
		int be;
		cin >> be;
		v.push_back(be);
	}
	vector<int> w;
	for (int i=0; i<m; i++) {
		int a;
		cin >> a;
		w.push_back(a);
	}
	sort(w.rbegin(), w.rend());
	int d=0;
	int c=1;
	for (int i:v) {
		for (int j=0; j<i; j++) {
			if (w.size()>0) {
				w.pop_back(); 
				}
				else {
					cout << d;
					return 0;
				}
				d++;
		}
		while(w[w.size()-1]==c) {
			if (w.size()>0) {
				w.pop_back(); 
				}
				else {
					cout << d;
					return 0;
				}
		}
		c++;
	}
	cout << d;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/034ms3184 KiB
3Accepted2/22ms2288 KiB
4Accepted2/22ms2336 KiB
5Accepted2/22ms2472 KiB
6Accepted2/24ms2628 KiB
7Accepted2/24ms2868 KiB
8Accepted2/23ms2916 KiB
9Accepted2/24ms3028 KiB
10Accepted2/23ms2988 KiB
11Accepted2/24ms3124 KiB
12Accepted2/24ms3296 KiB
13Accepted2/24ms3432 KiB
14Accepted2/24ms3396 KiB
15Accepted2/210ms3768 KiB
16Accepted2/212ms3948 KiB
17Accepted2/216ms4464 KiB
18Accepted2/212ms4260 KiB
19Accepted2/214ms4616 KiB
20Accepted2/218ms4888 KiB
21Accepted2/225ms5484 KiB
22Accepted2/234ms5504 KiB