6246 | 2023-11-08 13:46:58 | EsVagy | Karácsonyi égők | cpp17 | Forditási hiba |
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;
int main()
{
int l, c;
cin >> l >> c;
vector<int> colors(c);
int includedColors = 0;
vector<int> line;
for (int i = 0; i < l; i++)
{
int next;
cin >> next;
line.push_back(next);
}
int start = 0;
int end = 0;
int ans = INT_MAX;
while (end != l)
{
if (colors[line[end]] == 0)
{
includedColors++;
}
colors[line[end]]++;
while (colors[line[start]] > 1)
{
colors[line[start]]--;
start++;
}
if (includedColors == c)
{
ans = min(ans, end - start + 1);
}
end++;
}
cout << ans;
}
exit status 1
main.cpp: In function 'int main()':
main.cpp:25:19: error: 'INT_MAX' was not declared in this scope
25 | int ans = INT_MAX;
| ^~~~~~~
main.cpp:5:1: note: 'INT_MAX' is defined in header '<climits>'; did you forget to '#include <climits>'?
4 | #include <algorithm>
+++ |+#include <climits>
5 | using namespace std;
Exited with error status 1