Untitled

mail@pastecode.io avatar
unknown
c_cpp
7 months ago
416 B
0
Indexable
Never
#include <iostream> 
using namespace std;
int main()
{
	int disk = 0;
	int users = 0;
	int half_memory = 0;
	int u2 = 0;
	int u_am = 0;
	int u_mame;


	cin >> disk >> users;
	half_memory = disk / 2;

	for (int memory_u = 0; memory_u < users; memory_u++)
	{
		cin >> u_mame;
		if (u_mame <= half_memory and not (u2+u_mame > disk))
		{
			u2 += u_mame;
			u_am++;
		}

	}

	cout << u_am;

}
Leave a Comment