59842023-10-10 22:30:44CZHVállalkozócpp14Accepted 40/4034ms8096 KiB
// Source: https://usaco.guide/general/io

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

int main() {
	int days, works;
	int x, y;
	vector<int> daysVector;
	vector<int> worksVector;

	cin >> days >> works;
	for (int i = 0; i < days; i++) {
		cin >> x;
		daysVector.push_back(x);

	}

	for (int i = 0; i < works; i++) {
		cin >> y;
		worksVector.push_back(y);
	}
	sort(worksVector.begin(), worksVector.end());

	int cur = 0;
	int day = 0;
	int all = 0;

	for (int i = 0; i < worksVector.size(); i++) {
		if (cur == 0) {
			cur = daysVector[day];
			day++;
			if (day > daysVector.size()) {
				break;
			}
		}

		if (worksVector[i] >= day && cur>0) {
			all++;
			cur--;
		}
	}
	cout << all;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/034ms3648 KiB
3Accepted2/23ms2732 KiB
4Accepted2/23ms2956 KiB
5Accepted2/23ms2920 KiB
6Accepted2/24ms3212 KiB
7Accepted2/24ms3220 KiB
8Accepted2/23ms3496 KiB
9Accepted2/24ms3752 KiB
10Accepted2/23ms3900 KiB
11Accepted2/24ms4212 KiB
12Accepted2/24ms4428 KiB
13Accepted2/24ms4452 KiB
14Accepted2/24ms4748 KiB
15Accepted2/210ms4944 KiB
16Accepted2/212ms5048 KiB
17Accepted2/216ms5632 KiB
18Accepted2/210ms5580 KiB
19Accepted2/214ms5912 KiB
20Accepted2/217ms6404 KiB
21Accepted2/225ms7464 KiB
22Accepted2/234ms8096 KiB