5996 2023. 10. 12 09:33:24 zsebi Vállalkozó cpp11 Elfogadva 40/40 35ms 6044 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
Részfeladat Összpont Teszt Verdikt Idő Memória
base 40/40
1 Elfogadva 0/0 3ms 1812 KiB
2 Elfogadva 0/0 35ms 3480 KiB
3 Elfogadva 2/2 2ms 2212 KiB
4 Elfogadva 2/2 3ms 2428 KiB
5 Elfogadva 2/2 3ms 2644 KiB
6 Elfogadva 2/2 4ms 2876 KiB
7 Elfogadva 2/2 4ms 3236 KiB
8 Elfogadva 2/2 3ms 3540 KiB
9 Elfogadva 2/2 4ms 3656 KiB
10 Elfogadva 2/2 3ms 3760 KiB
11 Elfogadva 2/2 4ms 3880 KiB
12 Elfogadva 2/2 4ms 3960 KiB
13 Elfogadva 2/2 4ms 3988 KiB
14 Elfogadva 2/2 4ms 3968 KiB
15 Elfogadva 2/2 12ms 4408 KiB
16 Elfogadva 2/2 12ms 4272 KiB
17 Elfogadva 2/2 16ms 4860 KiB
18 Elfogadva 2/2 12ms 4656 KiB
19 Elfogadva 2/2 14ms 4716 KiB
20 Elfogadva 2/2 18ms 4932 KiB
21 Elfogadva 2/2 26ms 5312 KiB
22 Elfogadva 2/2 35ms 6044 KiB