結果
| 問題 |
No.37 遊園地のアトラクション
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-08-16 21:24:45 |
| 言語 | Nim (2.2.0) |
| 結果 |
AC
|
| 実行時間 | 16 ms / 5,000 ms |
| コード長 | 698 bytes |
| コンパイル時間 | 4,096 ms |
| コンパイル使用メモリ | 66,628 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-10 13:23:09 |
| 合計ジャッジ時間 | 5,363 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 27 |
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 41) Warning: Use the new 'sugar' module instead; future is deprecated [Deprecated] /home/judge/data/code/Main.nim(1, 41) Warning: imported and not used: 'future' [UnusedImport] /home/judge/data/code/Main.nim(1, 48) Warning: imported and not used: 'macros' [UnusedImport] /home/judge/data/code/Main.nim(1, 26) Warning: imported and not used: 'algorithm' [UnusedImport] /home/judge/data/code/Main.nim(1, 36) Warning: imported and not used: 'math' [UnusedImport]
ソースコード
import sequtils,strutils,algorithm,math,future,macros
template get*():string = stdin.readLine().strip()
template `max=`*(x,y:typed):void = x = max(x,y)
let
T = get().parseInt() # < 10000
N = get().parseInt() # < 15
C = get().split().map(parseInt) # < 100 # 残り時間
V = get().split().map(parseInt) # < 500 # 満足度
# 二回目以降は v div 2
var dp = newSeqWith(N+1,newSeqWith(T+1,0)) # 残り時間 T
for i in 0..<N:
var (cost,satis) = (C[i],V[i])
var sumSatis = satis
for t in 0..T: dp[i+1][t] = dp[i][t]
while satis > 0:
for t in cost..T:
dp[i+1][t-cost] .max= dp[i][t] + sumSatis
satis = satis div 2
cost += C[i]
sumSatis += satis
echo dp[^1][0]