58632023-10-04 17:05:47UVinceVállalkozócpp11Accepted 40/4041ms5356 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> days(n + 1);
	for (int i = 1; i < n + 1; i++) cin >> days[i];
	priority_queue<int> q;
	for (int i = 0; i < m; i++)
	{
		int a; cin >> a;
		q.push(0-a);
	}
	int done = 0, day=1;
	while (!q.empty()) {
		while (!q.empty() && 0-q.top() < day) q.pop();
		while (days[day] && !q.empty()) {
			done++;
			days[day]--;
			q.pop();
		}
		day++;
	}
	cout << done;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/041ms3184 KiB
3Accepted2/23ms2268 KiB
4Accepted2/23ms2516 KiB
5Accepted2/23ms2944 KiB
6Accepted2/24ms2928 KiB
7Accepted2/24ms3176 KiB
8Accepted2/23ms3220 KiB
9Accepted2/24ms3584 KiB
10Accepted2/23ms3536 KiB
11Accepted2/24ms3684 KiB
12Accepted2/24ms3828 KiB
13Accepted2/24ms4048 KiB
14Accepted2/24ms4012 KiB
15Accepted2/214ms4512 KiB
16Accepted2/214ms4556 KiB
17Accepted2/216ms4932 KiB
18Accepted2/212ms4560 KiB
19Accepted2/214ms4556 KiB
20Accepted2/221ms4800 KiB
21Accepted2/229ms5224 KiB
22Accepted2/241ms5356 KiB