結果

問題 No.45 回転寿司
ユーザー toshiro_yanagitoshiro_yanagi
提出日時 2018-06-17 01:42:38
言語 Nim
(2.0.2)
結果
WA  
実行時間 -
コード長 768 bytes
コンパイル時間 3,250 ms
コンパイル使用メモリ 70,240 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-13 06:17:49
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
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 AC 1 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 1 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,380 KB
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(26, 5) Warning: use `delete(s, first..last)`; delete is deprecated [Deprecated]

ソースコード

diff #

import strutils, sequtils, math, algorithm
var
  N, V = stdin.readLine.split.map parseInt
  cnt = 0
  flg: bool

proc check =
  var best = 0
  if V.len <= 4:
    for i in 0 ..< 2 ^ V.len:
      var
        pass: bool
        cnt_s = 0
      for j in 0 ..< V.len:
        if pass:
          pass = false
        elif i.toBin(V.len)[j] == '1':
          cnt_s += V[j]
          pass = true
      best = max(best, cnt_s)
    echo best + cnt
    quit()

proc eat =
  cnt += V[0]
  V.delete 0, 1
  flg = false

while true:
  check()
  if V[0] >= V[1]:
    eat()
  else:
    case V[0] + V[2] - (V[1] + V[3])
    of 0:
      if flg:
        eat()
      else:
        V.reverse
        flg = true
    of 1 .. int.high:
      eat()
    else:
      V.delete 0
      flg = false
0