結果

問題 No.318 学学学学学
ユーザー ikdikd
提出日時 2019-04-18 14:09:18
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 3,361 ms
コンパイル使用メモリ 69,972 KB
実行使用メモリ 28,404 KB
最終ジャッジ日時 2023-09-14 16:02:45
合計ジャッジ時間 6,463 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,312 KB
testcase_01 AC 11 ms
7,136 KB
testcase_02 AC 12 ms
7,048 KB
testcase_03 AC 9 ms
6,816 KB
testcase_04 AC 11 ms
7,180 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 41 ms
14,340 KB
testcase_17 AC 51 ms
24,536 KB
testcase_18 AC 49 ms
23,040 KB
testcase_19 AC 45 ms
22,800 KB
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,380 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:
    while stack.len > 0 and right[stack[^1]] < i:
      discard stack.pop
    if stack.len == 0 or stack[^1] < a[i]:
      stack.add(a[i])
    b[i] = stack[^1]
  echo b.map(proc(it: int): string = $it).join(" ")

main()
0