152882025-02-18 08:49:22zsebiLádapakolás raktárban (50)cpp17Hibás válasz 23/5057ms3716 KiB
// ladapakolas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <queue>
#include <map>
#define ll long long 
using namespace std;
ll n, m;
map<ll, ll>mp;
int main()
{
	cin >> n >> m;
	vector<ll>x(n + 1, 0);
	for (int i = 1; i <= n; ++i)cin >> x[i];
	int i = 1;
	ll elo = 0, db = 0,s=0;
	while (i <= n)
	{
		
		s = 0;
		
		while (i<n &&x[i]<x[i+1] && !mp[x[i]] && s + x[i] <= m)
		{
			mp[x[i]]++;
			db++;
			s += x[i];
			i++;
		}
		s += x[i];
		i++;
		
		while (i<=n &&x[i] < x[i-1] && !mp[x[i]] && s + x[i] <= m)
		{
			mp[x[i]]++;
			db++;
			s += x[i];
		
			i++;
		}
		
		mp.clear();
	}
	cout << db;
	return 0;
}
/*
* 12 16
1 3 5 4 2 6 8 7 6 5 3 4
*/

// 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ÖsszpontTesztVerdiktIdőMemória
base23/50
1Elfogadva0/01ms508 KiB
2Hibás válasz0/04ms316 KiB
3Elfogadva2/21ms508 KiB
4Elfogadva2/21ms316 KiB
5Hibás válasz0/21ms316 KiB
6Elfogadva2/21ms316 KiB
7Elfogadva2/21ms576 KiB
8Hibás válasz0/21ms508 KiB
9Elfogadva3/31ms508 KiB
10Hibás válasz0/21ms316 KiB
11Hibás válasz0/21ms316 KiB
12Hibás válasz0/22ms508 KiB
13Hibás válasz0/33ms536 KiB
14Hibás válasz0/33ms320 KiB
15Hibás válasz0/34ms476 KiB
16Hibás válasz0/229ms1076 KiB
17Hibás válasz0/339ms1192 KiB
18Hibás válasz0/350ms1076 KiB
19Elfogadva3/337ms1068 KiB
20Elfogadva3/357ms3176 KiB
21Elfogadva3/350ms3116 KiB
22Elfogadva3/352ms3716 KiB