Submission #75242458
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 -- nub O(n^2)
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
[n,k] <- readInts
as <- readInts
let bs = sortBy (flip compare) $ map (\g -> (head g * length g)) $ group $ sort as
if length bs <= k then
print 0
else do
let cand = drop k bs
print $ sum cand
Submission Info
| Submission Time | |
|---|---|
| Task | C - Vanish |
| User | haskboy |
| Language | Haskell (GHC 9.8.4) |
| Score | 300 |
| Code Size | 715 Byte |
| Status | AC |
| Exec Time | 503 ms |
| Memory | 58268 KiB |
Compile Error
Configuration is affected by the following files:
- cabal.project
- cabal.project.freeze
- cabal.project.local
app/Main.hs:4:1: warning: [GHC-66111] [-Wunused-imports]
The import of ‘Control.Monad’ is redundant
except perhaps to import instances from ‘Control.Monad’
To import instances alone, use: import Control.Monad()
|
4 | import Control.Monad
| ^^^^^^^^^^^^^^^^^^^^
app/Main.hs:12:1: warning: [GHC-40910] [-Wunused-top-binds]
Defined but not used: ‘readDoubles’
|
12 | readDoubles = map read . words . BS.unpack <$> BS.getLine
| ^^^^^^^^^^^
app/Main.hs:16:4: warning: [GHC-40910] [-Wunused-matches]
Defined but not used: ‘n’
|
16 | [n,k] <- readInts
| ^
app/Main.hs:18:48: warning: [GHC-63394] [-Wx-partial]
In the use of ‘head’
(imported from Data.List, 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."
|
18 | let bs = sortBy (flip compare) $ map (\g -> (head g * length g)) $ group $ sort as
| ^^^^
app/Main.hs:20:5: warning: [GHC-18042] [-Wtype-defaults]
• Defaulting the type variable ‘a0’ to type ‘Integer’ in the following constraints
(Show a0) arising from a use of ‘print’ at app/Main.hs:20:5-9
(Num a0) arising from the literal ‘0’ at app/Main.hs:20:11
• In the expression: print 0
In a stmt of a 'do' block:
if length bs <= k then
print 0
else
do let cand = ...
print $ sum cand
In the expression:
do [n, k] <- readInts
as <- readInts
let bs = sortBy (flip compare) $ map (\ g -> ...) $ group $ sort as
if length bs <= k then
print 0
else
do let ...
....
|
20 | print 0
| ^^^^^
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 | 300 / 300 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | sample00.txt, sample01.txt, sample02.txt |
| All | sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt, testcase14.txt, testcase15.txt, testcase16.txt, testcase17.txt, testcase18.txt, testcase19.txt, testcase20.txt, testcase21.txt, testcase22.txt, testcase23.txt, testcase24.txt, testcase25.txt, testcase26.txt, testcase27.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| sample00.txt | AC | 10 ms | 8628 KiB |
| sample01.txt | AC | 2 ms | 8480 KiB |
| sample02.txt | AC | 2 ms | 8228 KiB |
| testcase00.txt | AC | 2 ms | 8600 KiB |
| testcase01.txt | AC | 2 ms | 8284 KiB |
| testcase02.txt | AC | 404 ms | 51480 KiB |
| testcase03.txt | AC | 474 ms | 57316 KiB |
| testcase04.txt | AC | 303 ms | 44188 KiB |
| testcase05.txt | AC | 479 ms | 57496 KiB |
| testcase06.txt | AC | 160 ms | 31792 KiB |
| testcase07.txt | AC | 481 ms | 57264 KiB |
| testcase08.txt | AC | 12 ms | 18500 KiB |
| testcase09.txt | AC | 60 ms | 49416 KiB |
| testcase10.txt | AC | 52 ms | 21824 KiB |
| testcase11.txt | AC | 263 ms | 58268 KiB |
| testcase12.txt | AC | 129 ms | 32756 KiB |
| testcase13.txt | AC | 364 ms | 56332 KiB |
| testcase14.txt | AC | 358 ms | 52176 KiB |
| testcase15.txt | AC | 382 ms | 54396 KiB |
| testcase16.txt | AC | 416 ms | 49476 KiB |
| testcase17.txt | AC | 494 ms | 55616 KiB |
| testcase18.txt | AC | 35 ms | 17744 KiB |
| testcase19.txt | AC | 370 ms | 54256 KiB |
| testcase20.txt | AC | 403 ms | 50216 KiB |
| testcase21.txt | AC | 496 ms | 55328 KiB |
| testcase22.txt | AC | 59 ms | 51096 KiB |
| testcase23.txt | AC | 467 ms | 56324 KiB |
| testcase24.txt | AC | 503 ms | 55308 KiB |
| testcase25.txt | AC | 203 ms | 55248 KiB |
| testcase26.txt | AC | 358 ms | 54388 KiB |
| testcase27.txt | AC | 353 ms | 54280 KiB |