結果
問題 | No.297 カードの数式 |
ユーザー |
|
提出日時 | 2015-11-06 23:42:59 |
言語 | Haskell (9.10.1) |
結果 |
AC
|
実行時間 | 2 ms / 1,000 ms |
コード長 | 1,030 bytes |
コンパイル時間 | 4,772 ms |
コンパイル使用メモリ | 173,312 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-26 02:21:54 |
合計ジャッジ時間 | 5,720 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) [2 of 2] Linking a.out
ソースコード
-- yukicoder My Practice-- author: Leonardone @ NEETSDKASUimportData.Listmain = don <- getLinec <- getLineputStrLn $ solve csolve c =letcc = words c(mc, nm) = partition (== "-") cc(pc, np) = partition (== "+") nmsc = sort npfn1 _ 0 s cs = (s, cs)fn1 f n s (c:cs) = fn1 f (n - 1) (f s $ read c) cslm = length mclp = length pc(sm1, nm1) = fn1 (-) lm 0 sc(sm2, nm2) = fn1 (+) lp sm1 nm1maxsum = sm2 + (read $ reverse $ concat nm2)(sx1, nx1) = fn1 (+) (lp + 1) 0 sc(sx2, nx2) = if lm < 2then (sx1, nx1)else fn1 (-) (lm - 1) sx1 nx1minsum = if lm == 0then fn2 (lp + 1) (reverse sc) 1 0else sx2 - (read $ reverse $ concat nx2)inunwords $ map show [maxsum, minsum]fn2 _ [] _ s = sfn2 n xs b s =let(ys, zs) = splitAt n xssm = sum $ map read ysinfn2 n zs (b * 10) (sm * b + s)