結果

問題 No.8009 異なる数字の最大の範囲(勉強会用)
ユーザー koyumeishi
提出日時 2015-03-12 02:41:42
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 533 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,254 ms
コンパイル使用メモリ 104,904 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2026-07-26 05:31:33
合計ジャッジ時間 2,226 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
using namespace std;

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

	set<int> s;
	int ans = 0;
	int l = 0;
	// [l, r]
	for(int r=0; r<N; r++){
		auto itr = s.find( A[r] );
		if(itr != s.end()){
			s.clear();
			l = r;
		}
		s.insert( A[r] );
		ans = max(ans, r-l + 1);
	}

	cout << ans << endl;
	return 0;
}
0