#携程笔试# 水果组合题在自己电脑上运行结果是对的,提交出现了EOF when reading a line错误。有人知道原因嘛?

a=input().split(',')
b = [[item.count('a'), item.count('p')] for item in a]
m = int(input())
n = int(input())

def dp(index, m, n):
    if m <= 0 or n <= 0 or index < 0:
        return 0
    res = dp(index-1, m, n)
    if b[index][0] <= m and b[index][1] <= n:
        res = max(res, dp(index-1, m-b[index][0], n-b[index][1])+1)
    return res

print(dp(len(b)-1, m, n))
全部评论
while true: xxxxxxxxxxxxxxx except: break 这样的格式写
点赞 回复 分享
发布于 2021-04-29 19:13

相关推荐

迟缓的斜杠青年巴比Q...:简历被投过的公司卖出去了,我前两天遇到过更离谱的,打电话来问我有没有意向报班学Java学习,服了,还拿我学校一个学长在他们那报班学了之后干了华为OD当招牌
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 18:19
个个985的硕士闭着眼睛都有15k以上的月薪,天天嚷嚷着研究生白度读了,天天嚷嚷着反向读研了........
MMMJC:不读研22本科出去的基本都拿28k呢,你不能用25的研究生和25的本科生比然后说没反向读研,而是25研和22本比呀
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务