Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- single_input :: IO ->> Int
- Empty => Int IO.raw_input ""
- double_input :: IO ->> (Int, Int)
- Empty ~> {
- Empty => IO.raw_input "",
- raw => String.split raw " ",
- [a, b, ...c] => (Int a, Int b),
- }
- output_val :: Bool ->> IO
- True => IO.log <- 1
- False => IO.log <- 0
- borrow :: [Int], Int, Int ->> [Int]
- books, idx, dur => books[idx] = dur
- day_passing :: [Int] ->> [Int]
- books => @ (books''0 - 1)
- available :: [Int], Int ->> Maybe Bool
- book, idx | idx < 0 => Nothing
- book, idx | idx > length book => Nothing
- book, idx => book[idx] <= 0
- do:
- nbBooks, nbDays = double_input ()
- books = fill [0..nbBooks] 0
- for day in [0..nbDays]:
- for c in [0..single_input ()]:
- idx, dur = double_input ()
- avail = available books idx
- IO.log <- output_val avail
- if avail:
- borrow books idx dur
- books = day_passing books
Add Comment
Please, Sign In to add comment