はじめに
今回はC問題解けそうで解けずこんがらがってしまいました。
A問題
x,yそれぞれで範囲判定をする。
main = do
[p,q] <- readInts
[x,y] <- readInts
let ans = inRange (p,p+99) x && inRange (q,q+99) y
putStrLn $ bool "No" "Yes" ans
A問題提出
B問題
sで使われている文字がTakahashiの辞書で全て出てくるかつAokiの辞書で全て出てくるわけではない
のように判断すれば良い。
main = do
[n,m] <- readInts
s <- S.fromList <$> getLine
t <- S.fromList <$> getLine
q <- readLn :: IO Int
replicateM_ q $ do
w <- getLine
let x = all (`S.member` s) w
let y = all (`S.member` t) w
if x && not y then
putStrLn "Takahashi"
else if y && not x then
putStrLn "Aoki"
else
putStrLn "Unknown"
B問題提出
C問題
解説を見て解きました。似た考え方はできてましたが詰めが甘くWAの連発でした。
main = do
[n,k,x] <- readInts
as <- sortBy (flip compare) <$> readInts
let bs = drop (n-k) as
let y = count x 0 bs
if y == -1 then
print y
else
print $ (n-k) + y
count :: Int -> Int -> [Int] -> Int
count x i [] = -1
count x i (a:as)
| x1 <= 0 = i+1
| otherwise = count x1 (i+1) as
where
x1 = x - a
C問題提出
おわりに
最近Cがなかなか解けず苦戦が続いてる。。。意識してC問題の考察をきちんと行ってから解き始める癖をつけていきたい。