116652024-11-04 12:21:41bzyKarácsonyi égőkcpp17Time limit exceeded 30/1001.6s262144 KiB
#include <bits/stdc++.h>
using namespace std;
#define ll  long long

int main()
{
    int n, c; cin >> n >> c;
    vector <int> L(n+1);
    for(int i = 1; i <= n; i++) cin >> L[i];
    vector <vector <int> > dp(n + 1, vector <int>(c, 0));
    for(int i = 1; i <= n; i++){
        for(int j = 0; j < c; j++){
            dp[i][j] = dp[i-1][j];
        }
        dp[i][L[i]]++;
    }

    int ans = 0;
    for(int i = c; i <= n; i++){
        bool valid = true;
        for(int k = i; k <= n; k++){
            valid = true;
            for(int j = 0; j < c; j++){
                if(dp[k][j] - dp[k-i][j] <= 0) valid = false;
            }
            if(valid){
                ans = i;
                break;
            }
        }
        if(valid) break;
    }

    cout << ans;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms320 KiB
2Accepted1ms320 KiB
subtask20/15
3Time limit exceeded1.6s12452 KiB
4Time limit exceeded1.6s12316 KiB
5Time limit exceeded1.6s12336 KiB
6Accepted3ms324 KiB
7Accepted3ms320 KiB
subtask310/10
8Accepted1ms320 KiB
9Accepted1ms508 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms320 KiB
subtask420/20
13Accepted7ms568 KiB
14Accepted2ms320 KiB
15Accepted1ms508 KiB
16Accepted8ms912 KiB
17Accepted2ms320 KiB
subtask50/25
18Accepted97ms98388 KiB
19Time limit exceeded1.6s10296 KiB
20Accepted601ms10424 KiB
21Accepted87ms1028 KiB
22Accepted21ms568 KiB
subtask60/30
23Runtime error273ms262144 KiB
24Runtime error240ms262144 KiB
25Runtime error284ms262144 KiB
26Runtime error312ms262144 KiB
27Runtime error270ms262144 KiB
28Runtime error287ms262144 KiB
29Runtime error284ms262144 KiB
30Time limit exceeded1.593s12344 KiB