結果

問題 No.31 悪のミックスジュース
ユーザー tottoripaper
提出日時 2014-11-22 12:16:36
言語 Haskell
(9.10.1)
結果
WA  
実行時間 -
コード長 448 bytes
コンパイル時間 6,943 ms
コンパイル使用メモリ 185,984 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-02 20:05:25
合計ジャッジ時間 3,281 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 9
権限があれば一括ダウンロードができます
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.10.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