题目描述
一家神秘餐馆准备开放N天,牛牛 和 牛妹听到这个消息后,准备尽可能多的一起去吃午饭
餐馆有M道菜,牛牛和牛妹每次来只允许点一道菜,如果在第i天买了第j道菜
那么第i+7天也只能买第j道菜
第i天第j道菜的价格为price[i][j]
‘0’-'9’代表0-9美元
‘A’-'Z’代表10-35美元
‘a’-'z’代表36-61美元
牛牛和牛妹一共只有budget美元,请问他们最多可以吃几天的午饭
n, m, budget = map(int, input().split())
ll = []
for i in range(n):ll.append([])for j in range(m):ll[i].append(0)
l = []
for i in range(n):l = input()for j in range(m):ll[i][j] = l[j]for i in range(n):for j in range(m):if '0'<=ll[i][j]<='9':ll[i][j] = ord(ll[i][j]) - ord('0')elif 'A'<=ll[i][j]<='Z':ll[i][j] = ord(ll[i][j]) - ord('A') + 10elif 'a'<=ll[i][j]<='z':ll[i][j] = ord(ll[i][j]) - ord('a') + 36
a = []
for i in range(7):a.append([])for j in range(m):a[i].append(0)
b = []
cost = [0,0,0,0,0,0,0]
money = 0
for i in range(n):money -= cost[i%7];for j in range(m):a[i%7][j] += ll[i][j]b.append(a[i%7][j])cost[i%7] = min(b)money += cost[i%7]b = []if money > budget:print(i)break
else:print(n)