結果
| 問題 | 
                            No.8009 異なる数字の最大の範囲(勉強会用)
                             | 
                    
| ユーザー | 
                             yn
                         | 
                    
| 提出日時 | 2015-09-18 02:49:16 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 560 bytes | 
| コンパイル時間 | 432 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 24,464 KB | 
| 最終ジャッジ日時 | 2024-06-12 22:30:40 | 
| 合計ジャッジ時間 | 2,973 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 WA * 10 | 
ソースコード
n = int(input())
a = list(map(int,input().split()))
num = [False] * 1000001
length = 0
start = 0
best_s = 0
best_l = 0
i = 0
while i < n:
    if not num[a[i]]:
        num[a[i]] = True
        length += 1
        i += 1
    else:
        if start >= n:
            break
        while start < i and a[start] != a[i]:
            num[a[i]] = False
            start += 1
        num[a[i]] = True
        start += 1
        length = i - start + 1
        i += 1
    best_l = max(best_l, length)
    if best_l == length:
        best_s = start
print(best_l)
            
            
            
        
            
yn