結果
問題 | No.694 square1001 and Permutation 3 |
ユーザー | konsin_tokage |
提出日時 | 2018-06-24 09:18:18 |
言語 | Haskell (9.8.2) |
結果 |
MLE
|
実行時間 | - |
コード長 | 557 bytes |
コンパイル時間 | 4,182 ms |
コンパイル使用メモリ | 163,808 KB |
実行使用メモリ | 821,636 KB |
最終ジャッジ日時 | 2023-09-13 08:40:35 |
合計ジャッジ時間 | 10,558 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
7,484 KB |
testcase_01 | AC | 2 ms
7,408 KB |
testcase_02 | AC | 3 ms
7,412 KB |
testcase_03 | AC | 6 ms
10,900 KB |
testcase_04 | AC | 6 ms
11,256 KB |
testcase_05 | AC | 12 ms
11,844 KB |
testcase_06 | AC | 7 ms
11,884 KB |
testcase_07 | MLE | - |
testcase_08 | -- | - |
testcase_09 | -- | - |
testcase_10 | -- | - |
testcase_11 | -- | - |
testcase_12 | -- | - |
testcase_13 | -- | - |
コンパイルメッセージ
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
ソースコード
import Control.Monad import qualified Data.Set as S indexB x s = S.findIndex (x,0) s indexE x s = S.findIndex e s where Just e = S.lookupLE (x, maxBound :: Int) s count x s = indexE x s - indexB x s + 1 insert x s | S.member (x,0) s = S.insert (x, count x s) s | otherwise = S.insert (x,0) s solve n a = take n $ scanl step r a where ss@(s:_) = scanr insert S.empty a r = sum $ zipWith indexB a ss step r x = r + n - count x s - indexB x s * 2 main = do n <- readLn a <- replicateM n readLn :: IO [Integer] mapM_ print $ solve n a