結果
| 問題 | No.2194 兄弟の掛け引き |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-07 07:55:50 |
| 言語 | Standard ML (MLton 20241230) |
| 結果 |
AC
|
| 実行時間 | 1 ms / 1,000 ms |
| コード長 | 1,182 bytes |
| 記録 | |
| コンパイル時間 | 3,120 ms |
| コンパイル使用メモリ | 705,296 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-03-07 07:55:54 |
| 合計ジャッジ時間 | 3,799 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
fun quicksort [] = []
| quicksort (h::tl) =
let
val (s, b) =
List.foldl
(fn (x, (small, big)) =>
if x <= h then (x::small, big)
else (small, x::big))
([], [])
tl
in
(quicksort s) @ [h] @ (quicksort b)
end
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 printList [] = ignore ()
| printList (h :: tl) =
(
print (intString h);
print "\n";
printList tl
)
val () =
let
val a = readInt ()
val b = readInt ()
val c = readInt ()
val candidates = [(c + b) div a, c div a]
val filtered = List.filter (fn n =>
(0 < n * a - b andalso n * a - b = c) orelse
(n * a - b <= 0 andalso n * a = c))
candidates
val ans = if filtered = [] then [~1]
else quicksort filtered
in
printList ans
end