結果
| 問題 | No.143 豆 |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2026-08-20 11:14:47 |
| 言語 | Haskell (9.14.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| + 142µs | |
| コード長 | 655 bytes |
| 記録 | |
| コンパイル時間 | 912 ms |
| コンパイル使用メモリ | 195,200 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-08-20 11:14:50 |
| 合計ジャッジ時間 | 2,467 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.14.1/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
main :: IO ()
main = do
-- Read the first line and parse K, N, and F
firstLine <- getLine
let [k, n, f] = map read (words firstLine) :: [Int]
-- Read the second line and parse the ages
secondLine <- getLine
let ages = map read (words secondLine) :: [Int]
-- Calculate total beans available and total beans required
let totalBeans = k * n
let requiredBeans = sum ages
-- Calculate the remaining beans
let leftover = totalBeans - requiredBeans
-- Output -1 if there are not enough beans, otherwise output the leftover
if leftover < 0
then print (-1)
else print leftover
vjudge1