6522 | 2023-12-06 09:52:20 | CWM | Loud Snacks | cpp17 | Elfogadva 100/100 | 48ms | 11620 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
Részfeladat | Összpont | Teszt | Verdikt | Idő | Memória | ||
---|---|---|---|---|---|---|---|
subtask1 | 0/0 | ||||||
1 | Elfogadva | 3ms | 1812 KiB | ||||
2 | Elfogadva | 3ms | 2004 KiB | ||||
subtask2 | 18/18 | ||||||
3 | Elfogadva | 3ms | 2256 KiB | ||||
4 | Elfogadva | 3ms | 2444 KiB | ||||
5 | Elfogadva | 3ms | 2684 KiB | ||||
6 | Elfogadva | 3ms | 2920 KiB | ||||
7 | Elfogadva | 3ms | 3012 KiB | ||||
8 | Elfogadva | 3ms | 3144 KiB | ||||
9 | Elfogadva | 2ms | 3228 KiB | ||||
10 | Elfogadva | 3ms | 3480 KiB | ||||
11 | Elfogadva | 3ms | 3604 KiB | ||||
subtask3 | 21/21 | ||||||
12 | Elfogadva | 8ms | 4040 KiB | ||||
13 | Elfogadva | 9ms | 4208 KiB | ||||
14 | Elfogadva | 12ms | 4376 KiB | ||||
15 | Elfogadva | 14ms | 4460 KiB | ||||
16 | Elfogadva | 17ms | 4736 KiB | ||||
17 | Elfogadva | 19ms | 5236 KiB | ||||
18 | Elfogadva | 21ms | 5432 KiB | ||||
19 | Elfogadva | 25ms | 5964 KiB | ||||
20 | Elfogadva | 27ms | 6240 KiB | ||||
subtask4 | 36/36 | ||||||
21 | Elfogadva | 3ms | 5524 KiB | ||||
22 | Elfogadva | 3ms | 5776 KiB | ||||
23 | Elfogadva | 3ms | 5772 KiB | ||||
24 | Elfogadva | 3ms | 5908 KiB | ||||
25 | Elfogadva | 3ms | 5936 KiB | ||||
26 | Elfogadva | 3ms | 6016 KiB | ||||
27 | Elfogadva | 3ms | 5920 KiB | ||||
28 | Elfogadva | 3ms | 6040 KiB | ||||
subtask5 | 25/25 | ||||||
29 | Elfogadva | 34ms | 6872 KiB | ||||
30 | Elfogadva | 39ms | 7248 KiB | ||||
31 | Elfogadva | 43ms | 8180 KiB | ||||
32 | Elfogadva | 48ms | 8960 KiB | ||||
33 | Elfogadva | 48ms | 9740 KiB | ||||
34 | Elfogadva | 48ms | 10352 KiB | ||||
35 | Elfogadva | 48ms | 11028 KiB | ||||
36 | Elfogadva | 48ms | 11620 KiB |