59962023-10-12 09:33:24zsebiVállalkozócpp11Accepted 40/4035ms6044 KiB
// vallalkozo.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <algorithm>
#define ll long long 
using namespace std;

ll n, m;
int main()
{
	
	cin >> n >> m;
	vector<ll>x(n + 1);
	deque<ll>munka(m);
	for (int i = 1; i <= n; ++i)
	{
		cin >> x[i];
	}
	for (int i = 1; i <= m; ++i)
	{
		cin >> munka[i - 1];
	}
	sort(munka.begin(), munka.end());
	int i = 1,db=0;
	while (!munka.empty())
	{
		while (!munka.empty()&& munka[0] >= i && x[i] != 0)
		{
			munka.pop_front();
			x[i]--;
			db++;
		}
		if (x[i] == 0)
		{
			while (munka[0] == i)munka.pop_front();
		}
		++i;
	}
	cout << db;
   return 0;
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1812 KiB
2Accepted0/035ms3480 KiB
3Accepted2/22ms2212 KiB
4Accepted2/23ms2428 KiB
5Accepted2/23ms2644 KiB
6Accepted2/24ms2876 KiB
7Accepted2/24ms3236 KiB
8Accepted2/23ms3540 KiB
9Accepted2/24ms3656 KiB
10Accepted2/23ms3760 KiB
11Accepted2/24ms3880 KiB
12Accepted2/24ms3960 KiB
13Accepted2/24ms3988 KiB
14Accepted2/24ms3968 KiB
15Accepted2/212ms4408 KiB
16Accepted2/212ms4272 KiB
17Accepted2/216ms4860 KiB
18Accepted2/212ms4656 KiB
19Accepted2/214ms4716 KiB
20Accepted2/218ms4932 KiB
21Accepted2/226ms5312 KiB
22Accepted2/235ms6044 KiB