結果
| 問題 |
No.143 豆
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-10-26 23:54:00 |
| 言語 | Haskell (9.10.1) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 420 bytes |
| コンパイル時間 | 3,811 ms |
| コンパイル使用メモリ | 180,384 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 10:51:35 |
| 合計ジャッジ時間 | 3,945 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
コンパイルメッセージ
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:7:40: warning: [GHC-68441] [-Wdeprecations]
In the use of ‘getLine’ (imported from Data.ByteString):
Deprecated: "Deprecated since @bytestring-0.12@. Use 'Data.ByteString.Char8.getLine' instead. (Functions that rely on ASCII encodings belong in "Data.ByteString.Char8")"
|
7 | n <- (\(x:y:_) -> x * y).r <$> BS.getLine
| ^^^^^^^^^^
Main.hs:8:41: warning: [GHC-68441] [-Wdeprecations]
In the use of ‘getLine’ (imported from Data.ByteString):
Deprecated: "Deprecated since @bytestring-0.12@. Use 'Data.ByteString.Char8.getLine' instead. (Functions that rely on ASCII encodings belong in "Data.ByteString.Char8")"
|
8 | x <- foldr (g n) (Just 0).r <$> BS.getLine
| ^^^^^^^^^^
[2 of 2] Linking a.out
ソースコード
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BC
import Data.Maybe
main :: IO ()
main = do
n <- (\(x:y:_) -> x * y).r <$> BS.getLine
x <- foldr (g n) (Just 0).r <$> BS.getLine
print $ maybe (-1) (n-) x
where r = map (fst.fromJust.BC.readInt).BC.words
g n y (Just x) = if x + y > n then Nothing else Just (x + y)
g _ _ Nothing = Nothing