結果

問題 No.723 2つの数の和
ユーザー 👑 horiesinitihoriesiniti
提出日時 2018-12-09 16:18:32
言語 Haskell
(9.6.2)
結果
AC  
実行時間 413 ms / 2,000 ms
コード長 548 bytes
コンパイル時間 788 ms
コンパイル使用メモリ 163,652 KB
実行使用メモリ 46,348 KB
最終ジャッジ日時 2023-10-14 14:23:57
合計ジャッジ時間 7,305 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
7,236 KB
testcase_01 AC 2 ms
7,168 KB
testcase_02 AC 2 ms
7,240 KB
testcase_03 AC 302 ms
35,060 KB
testcase_04 AC 393 ms
41,740 KB
testcase_05 AC 362 ms
39,324 KB
testcase_06 AC 372 ms
40,188 KB
testcase_07 AC 143 ms
23,056 KB
testcase_08 AC 162 ms
23,528 KB
testcase_09 AC 383 ms
41,708 KB
testcase_10 AC 143 ms
24,556 KB
testcase_11 AC 32 ms
14,236 KB
testcase_12 AC 192 ms
23,784 KB
testcase_13 AC 413 ms
40,920 KB
testcase_14 AC 93 ms
20,204 KB
testcase_15 AC 163 ms
24,596 KB
testcase_16 AC 243 ms
29,176 KB
testcase_17 AC 343 ms
39,108 KB
testcase_18 AC 133 ms
22,712 KB
testcase_19 AC 262 ms
37,812 KB
testcase_20 AC 2 ms
7,104 KB
testcase_21 AC 2 ms
6,972 KB
testcase_22 AC 2 ms
7,040 KB
testcase_23 AC 252 ms
46,348 KB
testcase_24 AC 112 ms
20,988 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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 Data.List

f::[(Int,Int)]->[(Int,Int)]->Int->Int->Int
f [] _ _ ans=ans
f _ [] _ ans=ans
f xs2@((x,c1):xs) ys2@((y,c2):ys) n ans
      |x+y<n=f xs ys2 n ans
      |x+y>n=f xs2 ys n ans
      |otherwise=f xs ys n (ans+c1*c2)

main = do
       e<-getLine
       e2<-getLine
       let ts=map read (words e2)::[Int]
           xs=group $ sort $ ts
           ys=reverse xs
           (n:x:[])=map read (words e)::[Int]
           zs1=zip (map head xs) (map length xs)
           zs2=zip (map head ys) (map length ys)
       print $ f zs1 zs2 x 0
0