結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー krotonkroton
提出日時 2015-02-28 16:29:28
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 3,644 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 1,294 ms
コンパイル使用メモリ 158,428 KB
実行使用メモリ 7,740 KB
最終ジャッジ日時 2024-04-30 17:42:35
合計ジャッジ時間 6,538 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,308 KB
testcase_01 AC 3 ms
7,196 KB
testcase_02 AC 4 ms
7,220 KB
testcase_03 AC 3 ms
7,368 KB
testcase_04 AC 3 ms
7,196 KB
testcase_05 AC 3 ms
7,200 KB
testcase_06 AC 3 ms
7,116 KB
testcase_07 AC 3 ms
7,444 KB
testcase_08 AC 3 ms
7,400 KB
testcase_09 AC 3 ms
7,212 KB
testcase_10 AC 3 ms
7,252 KB
testcase_11 AC 3 ms
7,300 KB
testcase_12 AC 3 ms
7,344 KB
testcase_13 AC 3 ms
7,340 KB
testcase_14 AC 3 ms
7,408 KB
testcase_15 AC 110 ms
7,576 KB
testcase_16 AC 90 ms
7,484 KB
testcase_17 AC 113 ms
7,544 KB
testcase_18 AC 178 ms
7,740 KB
testcase_19 AC 127 ms
7,564 KB
testcase_20 AC 69 ms
7,504 KB
testcase_21 AC 26 ms
7,124 KB
testcase_22 AC 72 ms
7,408 KB
testcase_23 AC 39 ms
7,300 KB
testcase_24 AC 3,644 ms
7,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// もしかして通ったりして
#include <bits/stdc++.h>
using namespace std;

int N, A[100000];
int used[1000010];

int main(){
    memset(used, -1, sizeof(used));

    cin >> N;
    for(int i=0;i<N;i++){
        cin >> A[i];
    }

    int res = 0;
    for(int i=0;i<N;i++){
        int j = i;
        while(j < N && used[A[j]] != i){
            used[A[j]] = i;
            ++j;
        }

        res = max(res, j - i);
    }

    cout << res << endl;
    return 0;
}
0