65222023-12-06 09:52:20CWMLoud Snackscpp17Accepted 100/10048ms11620 KiB
// KKGyak.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
using namespace std;

#include <iostream>
#include <map>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <unordered_map>

int main()
{
    int n, maxL;
    cin >> n >> maxL;
	vector<int> sortedVec(n);
	for (size_t i = 0; i < n; i++)
	{
		cin >> sortedVec[i];
	}
	sort(sortedVec.begin(), sortedVec.end());
	int res = 0;
	for (size_t i = 0; i < sortedVec.size()-1;)
	{
		if (sortedVec[i+1] + sortedVec[i] <= maxL) {
			res++; 
			i += 2;
		}
		else {
			res++;
			i++;
		}
		if (i == sortedVec.size() - 1) res++;
	}
	cout << res;
}

// 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
subtask10/0
1Accepted3ms1812 KiB
2Accepted3ms2004 KiB
subtask218/18
3Accepted3ms2256 KiB
4Accepted3ms2444 KiB
5Accepted3ms2684 KiB
6Accepted3ms2920 KiB
7Accepted3ms3012 KiB
8Accepted3ms3144 KiB
9Accepted2ms3228 KiB
10Accepted3ms3480 KiB
11Accepted3ms3604 KiB
subtask321/21
12Accepted8ms4040 KiB
13Accepted9ms4208 KiB
14Accepted12ms4376 KiB
15Accepted14ms4460 KiB
16Accepted17ms4736 KiB
17Accepted19ms5236 KiB
18Accepted21ms5432 KiB
19Accepted25ms5964 KiB
20Accepted27ms6240 KiB
subtask436/36
21Accepted3ms5524 KiB
22Accepted3ms5776 KiB
23Accepted3ms5772 KiB
24Accepted3ms5908 KiB
25Accepted3ms5936 KiB
26Accepted3ms6016 KiB
27Accepted3ms5920 KiB
28Accepted3ms6040 KiB
subtask525/25
29Accepted34ms6872 KiB
30Accepted39ms7248 KiB
31Accepted43ms8180 KiB
32Accepted48ms8960 KiB
33Accepted48ms9740 KiB
34Accepted48ms10352 KiB
35Accepted48ms11028 KiB
36Accepted48ms11620 KiB