結果
| 問題 | No.8009 異なる数字の最大の範囲(勉強会用) |
| ユーザー |
小指が強い人
|
| 提出日時 | 2016-01-20 20:46:25 |
| 言語 | C++11(廃止可能性あり) (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 47 ms / 5,000 ms |
| コード長 | 673 bytes |
| 記録 | |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 70,036 KB |
| 実行使用メモリ | 8,200 KB |
| 最終ジャッジ日時 | 2024-11-20 15:00:45 |
| 合計ジャッジ時間 | 1,735 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#include <iostream>
#include <unordered_map>
using namespace std;
int main(void)
{
unordered_map<int, bool> h;
int n;
int a[100000] = {0};
cin >> n;
for(int i = 0; i < n; i++)
cin>> a[i];
int res = 0;
int j = 0;
for(int i = 0; i < n; i++) {
if(h.count(a[i]) == 0)
h[a[i]] = true;
else {
res = max(res, i - j);
while(true) {
h.erase(h.find(a[j]));
if(a[j] == a[i])
break;
j++;
}
h[a[i]] = true;
j++;
}
}
res = max(res, (int)h.size());
cout << res << endl;
}
小指が強い人