这题是不是评测数据可以不止二行?
  • 板块P1164 小A点菜
  • 楼主znzryb
  • 当前回复4
  • 已保存回复4
  • 发布时间2024/7/25 16:52
  • 上次更新2024/7/25 18:20:52
查看原帖
这题是不是评测数据可以不止二行?
1368189
znzryb楼主2024/7/25 16:52
22 20
2 3 3 4 5 4 5 5 10 23 4 5
10 10 10 10 10 10 17 18 19 20

为什么#4评测数据有三行啊。 我的代码可能就是因为这个RE了 仔细回去看题目好像没说只有两行

评测数据链接 https://www.luogu.com.cn/record/168493755

赋我的代码

# 小 A 奉行“不把钱吃光不罢休”的原则,所以他点单一定刚好把 uim 身上所有钱花完。他想知道有多少种点菜方法。
# https://www.luogu.com.cn/problem/P1164
# 由于小 A 肚子太饿,所以最多只能等待 1 秒  (指的是运行时间限制)

n_diet,m_money=map(int,input().split())
a=list(map(int,input().split()))
dp=[1]+[0]*(m_money)
for i in range(n_diet):
    diet_cost=a[i]
    for curr_money in range(m_money,0,-1):
        if curr_money >= diet_cost:
            if dp[curr_money-diet_cost] > 0:
                dp[curr_money]+=dp[curr_money-diet_cost]

print(dp[-1])
2024/7/25 16:52
加载中...