結果
問題 |
No.561 東京と京都
|
ユーザー |
![]() |
提出日時 | 2022-07-22 01:14:35 |
言語 | Nim (2.2.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 675 bytes |
コンパイル時間 | 4,971 ms |
コンパイル使用メモリ | 65,152 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-03 10:04:26 |
合計ジャッジ時間 | 5,050 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 8 WA * 9 |
ソースコード
import strutils, sequtils proc nextStr(): string = while not stdin.endOfFile: let c = stdin.readChar if c == '\r': continue if c in [' ', '\n']: break result.add(c) proc main(): void = let n, d = parseInt(nextStr()) var a = newSeqWith[n+1, [0, 0]] ans, p = 0 for i in 0..<n: let t, k = parseInt(nextStr()) a[i] = [t, k] for i in 0..<n: let noMove = a[i][p] + a[i+1][p] move1 = a[i][(p+1) mod 2] + a[i+1][(p+1) mod 2] - d move2 = a[i][(p+1) mod 2] + a[i+1][p] - 2*d if noMove < move1 or noMove < move2: p = (p+1) mod 2 ans -= d ans += a[i][p] echo ans when isMainModule: main()