6041 | 2023-10-28 18:54:47 | Gervid | Karácsonyi égők | cpp17 | Compilation error |
#include <iostream>
#include <vector>
#include <set>
using namespace std;
int main()
{
int n, c, i, out = INT_MAX;
cin >> n >> c;
vector<int> leds(n);
for (i = 0; i < n; i++)
{
cin >> leds[i];
}
vector<int> colors(c, 0);
set<int> present;
int back = 0;
i = 0;
while (i < n)
{
while (present.size() < c && i < n)
{
colors[leds[i]]++;
present.insert(leds[i]);
i++;
}
while (present.size() == c)
{
if (out > i - back)
{
out = i - back;
}
if (--colors[leds[back]] == 0)
{
present.erase(leds[back]);
}
back++;
}
}
cout << out;
}
//10 4
//0 1 3 0 0 1 2 0 2 3
exit status 1
main.cpp: In function 'int main()':
main.cpp:9:24: error: 'INT_MAX' was not declared in this scope
9 | int n, c, i, out = INT_MAX;
| ^~~~~~~
main.cpp:4:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
3 | #include <set>
+++ |+#include <climits>
4 |
Exited with error status 1