結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー kroton
提出日時 2015-02-28 16:29:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 3,808 ms / 5,000 ms
コード長 476 bytes
コンパイル時間 1,295 ms
コンパイル使用メモリ 158,496 KB
実行使用メモリ 7,668 KB
最終ジャッジ日時 2024-11-20 14:59:57
合計ジャッジ時間 6,855 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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