Submission #70769992
Source Code Expand
{-# OPTIONS_GHC -Wall #-}
{-# OPTIONS_GHC -Wname-shadowing #-} -- 内側のスコープの値と同じ名前が外側のスコープにあるとき警告する
import Control.Monad
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List
import qualified Data.IntSet as IS
readInts :: IO [Int]
readInts = unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
readDoubles :: IO [Double]
readDoubles = map read . words . BS.unpack <$> BS.getLine
main :: IO ()
main = do
x <- readLn :: IO Int
n <- readLn :: IO Int
ws <- readInts
q <- readLn :: IO Int
ps <- replicateM q readLn :: IO [Int]
putStr $ unlines $ map show $ solve IS.empty x ws ps
solve im w ws [] = []
solve im w ws (p:ps)
| IS.member p im = wSub : solve (IS.delete p im) wSub ws ps
| otherwise = wAdd : solve (IS.insert p im) wAdd ws ps
where
wSub = w - ws !! (p-1)
wAdd = w + ws !! (p-1)
Submission Info
| Submission Time | |
|---|---|
| Task | B - Robot Weight |
| User | haskboy |
| Language | Haskell (GHC 9.8.4) |
| Score | 200 |
| Code Size | 910 Byte |
| Status | AC |
| Exec Time | 22 ms |
| Memory | 9388 KiB |
Compile Error
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local
app/Main.hs:13:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readDoubles’
|
13 | readDoubles = map read . words . BS.unpack <$> BS.getLine
| ^^^^^^^^^^^
app/Main.hs:18:3: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘n’
|
18 | n <- readLn :: IO Int
| ^
app/Main.hs:24:1: warning: [GHC-38417] [-Wmissing-signatures]
Top-level binding with no type signature:
solve :: Num t => IS.IntSet -> t -> [t] -> [Int] -> [t]
|
24 | solve im w ws [] = []
| ^^^^^
app/Main.hs:24:7: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘im’
|
24 | solve im w ws [] = []
| ^^
app/Main.hs:24:10: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘w’
|
24 | solve im w ws [] = []
| ^
app/Main.hs:24:12: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘ws’
|
24 | solve im w ws [] = []
| ^^
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 200 / 200 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 22 ms | 8712 KiB |
| 00_sample_01.txt | AC | 2 ms | 8496 KiB |
| 01_random_02.txt | AC | 3 ms | 9388 KiB |
| 01_random_03.txt | AC | 3 ms | 9296 KiB |
| 01_random_04.txt | AC | 3 ms | 9156 KiB |
| 01_random_05.txt | AC | 3 ms | 9092 KiB |
| 01_random_06.txt | AC | 3 ms | 9348 KiB |
| 01_random_07.txt | AC | 3 ms | 9264 KiB |
| 01_random_08.txt | AC | 3 ms | 9388 KiB |
| 01_random_09.txt | AC | 3 ms | 9172 KiB |
| 01_random_10.txt | AC | 3 ms | 9108 KiB |
| 01_random_11.txt | AC | 3 ms | 9080 KiB |
| 01_random_12.txt | AC | 2 ms | 8780 KiB |
| 01_random_13.txt | AC | 3 ms | 9096 KiB |
| 01_random_14.txt | AC | 3 ms | 9104 KiB |
| 01_random_15.txt | AC | 3 ms | 9208 KiB |
| 01_random_16.txt | AC | 3 ms | 9032 KiB |