結果
問題 | No.451 575 |
ユーザー | okaduki |
提出日時 | 2016-12-07 00:36:17 |
言語 | Haskell (9.8.2) |
結果 |
AC
|
実行時間 | 289 ms / 2,000 ms |
コード長 | 874 bytes |
コンパイル時間 | 8,508 ms |
コンパイル使用メモリ | 180,296 KB |
実行使用メモリ | 70,784 KB |
最終ジャッジ日時 | 2024-05-09 19:32:12 |
合計ジャッジ時間 | 13,095 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 2 ms
5,376 KB |
testcase_05 | AC | 9 ms
9,472 KB |
testcase_06 | AC | 28 ms
17,536 KB |
testcase_07 | AC | 222 ms
70,784 KB |
testcase_08 | AC | 2 ms
5,376 KB |
testcase_09 | AC | 4 ms
5,888 KB |
testcase_10 | AC | 56 ms
20,352 KB |
testcase_11 | AC | 206 ms
57,856 KB |
testcase_12 | AC | 287 ms
70,272 KB |
testcase_13 | AC | 289 ms
70,144 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 6 ms
7,680 KB |
testcase_16 | AC | 25 ms
16,000 KB |
testcase_17 | AC | 216 ms
70,144 KB |
testcase_18 | AC | 216 ms
70,400 KB |
testcase_19 | AC | 131 ms
51,456 KB |
testcase_20 | AC | 9 ms
8,704 KB |
testcase_21 | AC | 4 ms
6,400 KB |
testcase_22 | AC | 2 ms
5,376 KB |
testcase_23 | AC | 289 ms
70,272 KB |
testcase_24 | AC | 149 ms
41,088 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 2 ms
5,376 KB |
testcase_27 | AC | 2 ms
5,376 KB |
testcase_28 | AC | 3 ms
5,376 KB |
testcase_29 | AC | 14 ms
11,776 KB |
testcase_30 | AC | 217 ms
70,144 KB |
testcase_31 | AC | 2 ms
5,376 KB |
testcase_32 | AC | 54 ms
25,984 KB |
コンパイルメッセージ
Loaded package environment from /home/judge/.ghc/x86_64-linux-9.8.2/environments/default [1 of 2] Compiling Main ( Main.hs, Main.o ) Main.hs:25:29: warning: [GHC-63394] [-Wx-partial] In the use of ‘head’ (imported from Prelude, but defined in GHC.List): "This is a partial function, it throws an error on empty lists. Use pattern matching or Data.List.uncons instead. Consider refactoring to use Data.List.NonEmpty." | 25 | bs <- forM [1..n] $ \_ -> head <$> getInteger | ^^^^ [2 of 2] Linking a.out
ソースコード
import Control.Applicative import Control.Monad import qualified Data.ByteString.Char8 as B import Data.Maybe (fromJust) import Text.Printf import Debug.Trace readInts :: B.ByteString -> [Integer] readInts = map (fst . fromJust . B.readInteger) . B.words getInteger :: IO [Integer] getInteger = liftM readInts B.getLine solve _ [] _ r = r solve i (x:xs) acc (l,r) = solve (i+1) xs acc' (l',r') where acc' = acc + (if (i+1) `mod` 4 < 2 then x else -x) (l',r') = if i `mod` 4 < 2 then (l,min r acc') else (max l acc',r) iter p = scanl (\(prv,f) x -> if f then (x-prv,False) else (prv-x,True)) (p,True) main = do [n] <- getInteger bs <- forM [1..n] $ \_ -> head <$> getInteger let (l,r) = solve 0 bs 0 (-1,2000000000000000000) if l+1 < r && 1 < r then print (n+1) >> forM_ (iter (r-1) bs) (print . fst) else print (-1)