61122023-11-01 16:25:56GhostKarácsonyi égőkcpp17Wrong answer 0/100162ms26524 KiB
#include <iostream>
#include <vector>
#include <set>
#include <limits.h>

using namespace std;

int main()
{
    int n, c, i, out = INT_MAX;
    cin >> n >> c;

    vector<int> lights(n);
    for (i = 0; i < n; i++) {
        cin >> lights[i];
    }

    vector<int> colors(c, 0);
    set<int> present;

    int back = 0;
    i = 0;
    while (i < n) {
        if (present.size() < c) {
            present.insert(lights[i]);
            colors[lights[i]]++;
        }
        if (present.size() == c) {
            if (out > i - back) {
                out = i - back;
            }
            colors[lights[back]]--;
            if (colors[lights[back]] == 0) {
                present.erase(lights[back]);
            }
            back++;
        }
        i++;
    }
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Wrong answer3ms1804 KiB
2Wrong answer3ms2060 KiB
subtask20/15
3Wrong answer39ms3672 KiB
4Wrong answer39ms3852 KiB
5Wrong answer39ms4052 KiB
6Wrong answer3ms2784 KiB
7Wrong answer3ms2912 KiB
subtask30/10
8Wrong answer3ms3120 KiB
9Wrong answer3ms3220 KiB
10Wrong answer3ms3308 KiB
11Wrong answer3ms3412 KiB
12Wrong answer2ms3456 KiB
subtask40/20
13Wrong answer3ms3716 KiB
14Wrong answer3ms4072 KiB
15Wrong answer3ms4052 KiB
16Wrong answer3ms4004 KiB
17Wrong answer3ms4108 KiB
subtask50/25
18Wrong answer4ms4760 KiB
19Wrong answer4ms4520 KiB
20Wrong answer4ms4716 KiB
21Wrong answer4ms4784 KiB
22Wrong answer4ms4824 KiB
subtask60/30
23Wrong answer162ms26524 KiB
24Wrong answer61ms6152 KiB
25Wrong answer71ms6616 KiB
26Wrong answer101ms11476 KiB
27Wrong answer119ms16372 KiB
28Wrong answer71ms6648 KiB
29Wrong answer59ms6404 KiB
30Wrong answer39ms6296 KiB