結果
| 問題 |
No.3009 Union-Find でつながろう!
|
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 21:08:39 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 641 bytes |
| コンパイル時間 | 145 ms |
| コンパイル使用メモリ | 82,412 KB |
| 実行使用メモリ | 67,476 KB |
| 最終ジャッジ日時 | 2025-03-20 21:09:28 |
| 合計ジャッジ時間 | 3,901 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 3 |
| other | RE * 27 |
ソースコード
n = int(input())
if n == 0:
print(0)
exit()
arr = list(map(int, input().split()))
last_occurrence = {}
max_length = 0
left = 0
for right in range(n):
current = arr[right]
if current in last_occurrence:
# Ensure left pointer moves to the right of the last occurrence of current
left = max(left, last_occurrence[current] + 1)
# Update the last occurrence of the current element
last_occurrence[current] = right
# Calculate the current window length and update max_length
current_length = right - left + 1
if current_length > max_length:
max_length = current_length
print(max_length)
lam6er