結果

問題 No.3009 異なる数字の最大の範囲(勉強会用)
ユーザー yozayoza
提出日時 2015-02-28 17:09:20
言語 Nim
(2.0.2)
結果
AC  
実行時間 19 ms / 5,000 ms
コード長 410 bytes
コンパイル時間 3,830 ms
コンパイル使用メモリ 66,060 KB
実行使用メモリ 16,844 KB
最終ジャッジ日時 2024-04-30 17:42:16
合計ジャッジ時間 4,171 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
10,776 KB
testcase_01 AC 4 ms
10,840 KB
testcase_02 AC 3 ms
10,788 KB
testcase_03 AC 3 ms
10,788 KB
testcase_04 AC 3 ms
10,828 KB
testcase_05 AC 3 ms
10,804 KB
testcase_06 AC 4 ms
10,828 KB
testcase_07 AC 4 ms
10,788 KB
testcase_08 AC 4 ms
10,832 KB
testcase_09 AC 3 ms
10,876 KB
testcase_10 AC 3 ms
10,832 KB
testcase_11 AC 3 ms
10,848 KB
testcase_12 AC 4 ms
10,772 KB
testcase_13 AC 4 ms
10,936 KB
testcase_14 AC 4 ms
10,768 KB
testcase_15 AC 14 ms
14,428 KB
testcase_16 AC 11 ms
13,352 KB
testcase_17 AC 13 ms
14,556 KB
testcase_18 AC 19 ms
16,844 KB
testcase_19 AC 14 ms
14,788 KB
testcase_20 AC 9 ms
12,368 KB
testcase_21 AC 6 ms
11,552 KB
testcase_22 AC 10 ms
13,204 KB
testcase_23 AC 7 ms
12,288 KB
testcase_24 AC 18 ms
16,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 39) Warning: imported and not used: 'math' [UnusedImport]
/home/judge/data/code/Main.nim(1, 28) Warning: imported and not used: 'algorithm' [UnusedImport]

ソースコード

diff #

import strutils, sequtils, algorithm, math


var
  n = readLine(stdin).parseInt()
  a_seq = readLine(stdin).split(' ').map(parseInt)
  inchworm = newSeq[int](1_000_002)
  right, tmp_a : int
  left, max_len = 0

for right in countup(1, n):
  tmp_a = a_seq[right - 1]
  if inchworm[tmp_a] > 0:
    left = max(inchworm[tmp_a], left)
  max_len = max(max_len, right - left)
  inchworm[tmp_a] = right

echo(max_len)
0