夢追い人

"It takes a dreamer to make a dream come true."―Vincent Willem van Gogh

arc8

pythonで解いてhaskellの正解コード見て対応づけるみたいなことやろうとしたけど見ての通り

A

#!/usr/bin/env python
# coding: utf-8

n = int(raw_input())

res = n * 15
for i in range(1, int(n / 10) + 2):
    temp = (n - i * 10) * 15
    if temp < 0: temp = 0
    temp += i * 100
    res = min(res, temp)
print res
check n
    | n >= 7 = 100
    | otherwise = n * 15

main = do
    n <- fmap(read :: String->Int) getLine
    print $ 100 * (div n 10) + check (mod n 10)

全然解き方違う…いや僕のが頭わるいだけか

B

#! /usr/bin/env python
# coding: utf-8

(n, m) = map(int, raw_input().split(' '))
name = raw_input()
kit = raw_input()

ndict = {}
kdict = {}

for i in name:
    ndict.setdefault(i, 0)
    ndict[i] += 1
for i in kit:
    kdict.setdefault(i, 0)
    kdict[i] += 1

res = 0
for k, v in ndict.iteritems():
    if kdict.get(k) == None: res = -1; break
    res = max(res, (v + kdict[k] - 1) / kdict[k])

print res

ここであきらめ(笑)

広告を非表示にする