結果

問題 No.31 悪のミックスジュース
ユーザー tottoripapertottoripaper
提出日時 2014-11-22 12:16:36
言語 Haskell
(9.8.2)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 11,199 ms
コンパイル使用メモリ 162,760 KB
実行使用メモリ 8,212 KB
最終ジャッジ日時 2023-08-30 22:11:56
合計ジャッジ時間 2,242 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 3 ms
8,128 KB
testcase_05 AC 3 ms
8,212 KB
testcase_06 AC 2 ms
7,172 KB
testcase_07 AC 3 ms
7,988 KB
testcase_08 AC 3 ms
7,860 KB
testcase_09 WA -
testcase_10 AC 3 ms
8,008 KB
testcase_11 WA -
testcase_12 AC 3 ms
7,800 KB
testcase_13 AC 2 ms
7,380 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.6.1/environments/default
[1 of 2] Compiling Main             ( Main.hs, Main.o )
[2 of 2] Linking a.out

ソースコード

diff #

import Control.Applicative
import Data.List (sortBy)
import Data.Int

readInts :: IO [Int64]
readInts = map read . words <$> getLine

main = do
  [n, v] <- readInts
  cs <- readInts
  let
    comp (x,y) (x',y') = compare (x*y') (x'*y)
    total = sum cs
    cs' = sortBy comp $ zip (scanl1 (+) cs) [1..]
    f 0 _ = 0
    f x ((a,b):ys) = a * (x `div` b) + f (x `mod` b) ys
   in print $ if v < n then total else total + f (v-n) cs'
0