結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー mtrhmtrh
提出日時 2021-04-03 11:31:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 382 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 174,952 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-04-30 17:45:54
合計ジャッジ時間 4,125 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 1 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 1 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 41 ms
6,944 KB
testcase_16 AC 37 ms
6,940 KB
testcase_17 AC 40 ms
6,940 KB
testcase_18 AC 75 ms
7,936 KB
testcase_19 AC 48 ms
6,944 KB
testcase_20 AC 25 ms
6,944 KB
testcase_21 AC 12 ms
6,940 KB
testcase_22 AC 29 ms
6,944 KB
testcase_23 AC 15 ms
6,944 KB
testcase_24 AC 63 ms
8,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    map<int,int> mp;
    int ans=0;
    int t=0;
    for(int i=0;i<N;i++){
        t++;
        t=min(t,i+1-mp[A[i]]);
        ans=max(ans,t);
        mp[A[i]]=i+1;
    }
    cout<<ans<<endl;
    return 0;
}
0