結果
| 問題 | No.231 めぐるはめぐる (1) | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2018-09-15 21:04:14 | 
| 言語 | Haskell (9.10.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 1,000 ms | 
| コード長 | 517 bytes | 
| コンパイル時間 | 2,175 ms | 
| コンパイル使用メモリ | 171,520 KB | 
| 実行使用メモリ | 8,576 KB | 
| 最終ジャッジ日時 | 2024-07-18 07:15:06 | 
| 合計ジャッジ時間 | 3,013 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 11 | 
コンパイルメッセージ
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:20:21: 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."
   |
20 |     let (no, eff) = head $ sortBy by ds
   |                     ^^^^
[2 of 2] Linking a.out
            
            ソースコード
module Main where
import Control.Monad
import Data.List (sortBy)
expNeeded = 30000 * 100
desupena = 30000
exp_h :: [Int] -> Int
exp_h [g, d] = g - d * desupena
by (_, a) (_, b) = b `compare` a
main :: IO ()
main = do
    n <- readLn
    ds <- fmap (zip [1..])
            . replicateM n
            $ exp_h . fmap read . words <$> getLine
    let (no, eff) = head $ sortBy by ds
    if eff * 6 < expNeeded
        then putStrLn "NO"
        else do
            putStrLn "YES"
            replicateM_ 6 (print no)
            
            
            
        