結果

問題 No.318 学学学学学
ユーザー ikdikd
提出日時 2019-04-18 14:03:39
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 510 bytes
コンパイル時間 3,250 ms
コンパイル使用メモリ 69,888 KB
実行使用メモリ 27,560 KB
最終ジャッジ日時 2023-09-14 16:01:31
合計ジャッジ時間 5,902 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 11 ms
7,024 KB
testcase_02 AC 12 ms
7,064 KB
testcase_03 AC 10 ms
6,688 KB
testcase_04 AC 11 ms
7,144 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 42 ms
14,560 KB
testcase_17 AC 50 ms
24,936 KB
testcase_18 AC 48 ms
23,200 KB
testcase_19 AC 45 ms
23,196 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,376 KB
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,376 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,376 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import strutils, sequtils, tables

proc main() =
  let
    n = stdin.readLine.strip.parseInt
    a = stdin.readLine.strip.split.map(parseInt)
  var right = initTable[int, int]()
  for i in 0..<n:
    right[a[i]] = i
  var
    stack = newSeq[int]()
    b = newSeq[int](n)
  for i in 0..<n:
    if stack.len == 0 or stack[^1] < a[i]:
      stack.add(a[i])
    b[i] = stack[^1]
    while stack.len > 0 and right[stack[^1]] <= i:
      discard stack.pop
  echo b.map(proc(it: int): string = $it).join(" ")

main()
0