結果
| 問題 | No.2138 Add Bacon |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-04 11:48:56 |
| 言語 | Standard ML (MLton 20241230) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 2,000 ms |
| コード長 | 752 bytes |
| 記録 | |
| コンパイル時間 | 4,561 ms |
| コンパイル使用メモリ | 705,160 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-04 11:49:05 |
| 合計ジャッジ時間 | 5,669 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 25 |
ソースコード
fun readInt () =
valOf (TextIO.scanStream (Int.scan StringCvt.DEC) TextIO.stdIn)
fun intString n =
if 0 <= n
then Int.toString n
else "-" ^ Int.toString (abs n)
fun findAns a b c d e =
let
fun findAnsAux deliciousness calories bacon maxHappiness =
if c <= bacon then maxHappiness
else findAnsAux (deliciousness + d) (calories + e) (bacon + 1) (Int.max((deliciousness + d) - (calories + e), maxHappiness))
in
findAnsAux a b 0 (a - b)
end
val () =
let
val a = readInt ()
val b = readInt ()
val c = readInt ()
val d = readInt ()
val e = readInt ()
val ans = findAns a b c d e
in
print (intString ans ^ "\n")
end