n, k, s = map(int, input().split()) lis1 = [0 for i in range(s+1)] lis2 = [0 for i in range(s+1)] day = [i for i in range(n+1)] lis3 = [0 for i in range(n+1)] ans = 0 for i in range(1,s+1): lis1[i], lis2[i]= map(int, input().split()) for a in day: if a == lis1[i]: lis3[lis1.index(a)]+=lis2[i] for j in range(n+1): if lis3[j]>=k: ans+=1 print(n-ans) 帮我优化一下代码
时间: 2023-05-27 19:07:00 浏览: 184
我们第一行包括两个整数n,k(1<=n<=100,k<=6e5),表示有n个数字,目标和为k 第二行输入n个整数(c1 c2
n, k, s = map(int, input().split())
lis = [0] * n
for i in range(s):
a, b = map(int, input().split())
lis[a-1] = max(lis[a-1], b)
ans = sum(1 for x in lis if x < k)
print(ans)
阅读全文