結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー 👑 CleyL
提出日時 2021-12-08 09:16:28
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 447 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2024-06-12 22:38:34
合計ジャッジ時間 1,926 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <set>
#include <queue>
using namespace std;
int main(){
    int n;cin>>n;
    set<int> A;
    queue<int> B;
    int ans = 0;
    for(int i = 0; n > i; i++){
        int x;cin>>x;
        if(A.count(x)){
            while(B.front() == x){
                B.pop();
            }
            B.pop();
        }
        B.push(x);
        A.insert(x);
        ans = max(ans,(int)B.size());
    }
    cout << ans << endl;
}
0