結果

問題 No.885 アマリクエリ
ユーザー torikuminotorikumino
提出日時 2019-09-19 21:07:01
言語 Haskell
(9.8.2)
結果
AC  
実行時間 1,654 ms / 2,000 ms
コード長 459 bytes
コンパイル時間 3,063 ms
コンパイル使用メモリ 164,876 KB
実行使用メモリ 134,632 KB
最終ジャッジ日時 2023-09-27 10:29:52
合計ジャッジ時間 15,438 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 504 ms
76,688 KB
testcase_01 AC 1,503 ms
134,632 KB
testcase_02 AC 923 ms
129,016 KB
testcase_03 AC 773 ms
116,192 KB
testcase_04 AC 794 ms
125,100 KB
testcase_05 AC 524 ms
82,908 KB
testcase_06 AC 302 ms
39,276 KB
testcase_07 AC 424 ms
71,604 KB
testcase_08 AC 312 ms
38,328 KB
testcase_09 AC 1,654 ms
134,616 KB
testcase_10 AC 2 ms
7,408 KB
testcase_11 AC 2 ms
7,444 KB
testcase_12 AC 2 ms
7,524 KB
testcase_13 AC 22 ms
12,660 KB
testcase_14 AC 22 ms
12,676 KB
testcase_15 AC 22 ms
12,720 KB
testcase_16 AC 12 ms
12,408 KB
testcase_17 AC 12 ms
12,440 KB
testcase_18 AC 11 ms
12,860 KB
testcase_19 AC 12 ms
11,812 KB
testcase_20 AC 7 ms
11,688 KB
testcase_21 AC 12 ms
11,796 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 qualified Data.Map.Strict as M

query (v,m) x = (w, o)
  where
    (lt,ge) = M.spanAntitone (< x) m
    n = M.mapKeysWith (+) (`mod` x) ge
    w = v - count ge + count n
    o = M.unionWith (+) n lt

count m = sum [k*v | (k,v) <- M.toList m]

main = do
  getLine
  a <- map read . words <$> getLine
  getLine
  xs <- map read . words <$> getLine
  let m = M.fromListWith (+) $ zip a [1,1..] 
  mapM_  print $ map fst $ tail $ scanl query (sum a, m) xs
0