結果
| 問題 |
No.561 東京と京都
|
| コンテスト | |
| ユーザー |
toshiro_yanagi
|
| 提出日時 | 2019-01-04 20:26:00 |
| 言語 | Nim (2.2.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,374 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 66,172 KB |
| 最終ジャッジ日時 | 2024-11-14 20:45:07 |
| 合計ジャッジ時間 | 1,240 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 25) Error: cannot open file: queues
ソースコード
import sugar, strutils, queues
proc nextString: string =
result = ""
while not endOfFile stdin:
let nextChar = readChar stdin
case nextChar
of '\r':
discard
of "\n"[0], ' ':
break
else:
add result, nextChar
proc nextInt: int =
parseInt nextString()
let
n, driveCst = nextInt()
TK = lc[(nextInt(), nextInt()) | (i <- 0 ..< n), tuple[tyo, kyo: int]]
var
earningsTyo, earningsKyo = lc[int.low | (i <- 0 .. n), int]
proc bfs: int =
var Q = initQueue[tuple[day, pool: int, place: char]]()
enqueue Q, (0, 0, 't')
while Q.len != 0:
let q = dequeue Q
if q.day == n:
continue
for p in ['t', 'k']:
var poolNow = q.pool - driveCst * int(p != q.place)
if p == 't':
poolNow += TK[q.day].tyo
if earningsTyo[q.day + 1] < poolNow:
enqueue Q, (q.day + 1, poolNow, 't')
earningsTyo[q.day + 1] = poolNow
if p == 'k':
poolNow += TK[q.day].kyo
if earningskyo[q.day + 1] < poolNow:
enqueue Q, (q.day + 1, poolNow, 'k')
earningsKyo[q.day + 1] = poolNow
max(earningsTyo[n], earningsKyo[n])
proc main: void =
echo bfs()
if isMainModule:
main()
toshiro_yanagi