import sys def get_buyable(P, money): curmax = 0 curid = -1 for i in range(len(P)): if P[i] <= money: if P[i] > curmax: curmax = P[i] curid = i if curid == -1: return -1, -1 else: return curid, curmax n = int(sys.stdin.readline().strip()) values = [] for i in range(n): k = int(sys.stdin.readline().strip()) line = sys.stdin.readline().strip() P = list(map(int, line.split())) values.append(P) q = int(sys.stdin.readline().strip()) Q = [] for j in range(q): line = sys.stdin.readline().strip() x, y, z = list(map(int, line.split())) money = x * y * z curid, curmax = get_buyable(P, money) if curid == -1: print(-1) else: print(curid + 1, curmax) 我怀疑过价格是不是从小到大,可以二分查找,但我试了2分查找,也是超时好吧
点赞 2

相关推荐

Twilight_m...:还是不够贴近现实,中关村那块60平房子200万怎么可能拿的下来,交个首付还差不多
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务