Submission #1484550
Source Code Expand
import Control.Monad import Data.Maybe main :: IO () main = do n <- readLn :: IO Int as <- getInts bs <- getInts let as'= decide as bs' = reverse $ decide (reverse bs) ms = zipWith min as bs xs = solve as' bs' ms -- print as' -- print bs' -- print xs print $ fromMaybe 0 (solve' <$> xs) getInts :: IO [Int] getInts = map read . words <$> getLine decide :: [Int] -> [Int] decide ns = go (zip ns (0 : init ns)) where go [] = [] go ((c, n):xs) | c == n = -c : go xs | otherwise = c : go xs solve :: [Int] -> [Int] -> [Int] -> Maybe [Int] solve as bs mins = go as bs mins where go [] _ _ = Just [] go (x:xs) (y:ys) (m:ms) | x == y && x > 0= go xs ys ms | y < 0 && x < 0 = (m :) <$> go xs ys ms | y + x <= 0 = go xs ys ms | otherwise = Nothing solve' :: [Int] -> Int solve' ns = go ns where go [] = 1 go (n:ns) = (n * go ns) `mod` 1000000007
Submission Info
Submission Time | |
---|---|
Task | C - Two Alpinists |
User | nmjiri |
Language | Haskell (GHC 7.10.3) |
Score | 400 |
Code Size | 986 Byte |
Status | AC |
Exec Time | 1385 ms |
Memory | 143740 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt |
All | 0_000.txt, 0_001.txt, 0_002.txt, 0_003.txt, 1_004.txt, 1_005.txt, 1_006.txt, 1_007.txt, 1_008.txt, 1_009.txt, 1_010.txt, 1_011.txt, 1_012.txt, 1_013.txt, 1_014.txt, 1_015.txt, 1_016.txt, 1_017.txt, 1_018.txt, 1_019.txt, 1_020.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_000.txt | AC | 2 ms | 508 KB |
0_001.txt | AC | 2 ms | 508 KB |
0_002.txt | AC | 2 ms | 636 KB |
0_003.txt | AC | 1 ms | 508 KB |
1_004.txt | AC | 1 ms | 508 KB |
1_005.txt | AC | 2 ms | 508 KB |
1_006.txt | AC | 2 ms | 508 KB |
1_007.txt | AC | 2 ms | 508 KB |
1_008.txt | AC | 1385 ms | 143740 KB |
1_009.txt | AC | 1127 ms | 106876 KB |
1_010.txt | AC | 1205 ms | 114684 KB |
1_011.txt | AC | 1260 ms | 126332 KB |
1_012.txt | AC | 772 ms | 111996 KB |
1_013.txt | AC | 1264 ms | 125820 KB |
1_014.txt | AC | 779 ms | 113020 KB |
1_015.txt | AC | 1269 ms | 127996 KB |
1_016.txt | AC | 844 ms | 122492 KB |
1_017.txt | AC | 1203 ms | 114812 KB |
1_018.txt | AC | 918 ms | 111612 KB |
1_019.txt | AC | 1075 ms | 101756 KB |
1_020.txt | AC | 688 ms | 94588 KB |