Submission #1954216


Source Code Expand

import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
--import Data.Array
import Data.Array.IArray
--import Data.Array.Unboxed
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
-- import System.IO.Unsafe
 
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
dictCompare :: [a -> a -> Ordering] -> a -> a -> Ordering
dictCompare [] _ _ = EQ
dictCompare (f:fs) x y = let c = f x y in if c==EQ then dictCompare fs x y else c
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
-- end of templete


main = do
    [n,y] <- getInts
    let y' = div y 1000
    let c = y' - n
    let r = [(x, y, z) | x <- [0..c`div`9], let (y,r) = divMod (c-9*x) 4, let z = n - x - y, r==0, y<=n, z>=0, z<=n]
    putStrLn $ if null r then "-1 -1 -1" else let (x,y,z) = head r in sjoin [x,y,z]

Submission Info

Submission Time
Task C - Otoshidama
User refle
Language Haskell (GHC 7.10.3)
Score 300
Code Size 2364 Byte
Status AC
Exec Time 2 ms
Memory 508 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 4
AC × 24
Set Name Test Cases
Sample a01, a02, a03, a04
All a01, a02, a03, a04, b05, b06, b07, b08, b09, b10, b11, b12, b13, b14, b15, b16, b17, b18, b19, b20, b21, b22, b23, b24
Case Name Status Exec Time Memory
a01 AC 2 ms 508 KB
a02 AC 2 ms 508 KB
a03 AC 2 ms 508 KB
a04 AC 2 ms 508 KB
b05 AC 2 ms 508 KB
b06 AC 2 ms 508 KB
b07 AC 2 ms 508 KB
b08 AC 2 ms 508 KB
b09 AC 2 ms 508 KB
b10 AC 2 ms 508 KB
b11 AC 2 ms 508 KB
b12 AC 2 ms 508 KB
b13 AC 2 ms 508 KB
b14 AC 2 ms 508 KB
b15 AC 2 ms 508 KB
b16 AC 2 ms 508 KB
b17 AC 2 ms 508 KB
b18 AC 2 ms 508 KB
b19 AC 2 ms 508 KB
b20 AC 2 ms 508 KB
b21 AC 2 ms 508 KB
b22 AC 2 ms 508 KB
b23 AC 2 ms 508 KB
b24 AC 2 ms 508 KB