360 24号,两题100,AC代码

第一题基本暴力解,注意不是所有的字母都是对称的就可以
第二题注意首先没有宝物的关卡先过完,然后注意有宝物的关卡使用宝物的时机是,该关卡的分数大于之前所有关卡的分数的和
代码如下:
# 第一题
sameLetters = ['A', 'H', 'I', 'M', 'O', 'T', 'U', 'V', 'W', 'X', 'Y']

while True:
    _str = input()
    if len(_str)<=0:
        break
    half = len(_str) // 2 +1
    lenght = len(_str)

    #print(half, lenght)
    isYes = True
    for i in range(half):
        if not (_str[i] == _str[lenght - i-1] and _str[i] in sameLetters):
            isYes = False
            break
    if isYes:
        print("YES")
    else:
        print("NO")
#第二题
import numpy as np
k = int(input())
scores = 0
listb0 = []
listb1 = []
for i in range(k):
    a, b = map(int, input().split())
    if b == 0:
        listb0.append(a)
    else:
        listb1.append(a)
npb0 = np.array(sorted(listb0, reverse=True))
npb1 = np.array(sorted(listb1, reverse=True))

score0 = sum(npb0)
indexnpb1 = 0
for i in range(len(npb1)):
    if score0 < npb1[i]:
        score0 += npb1[i]
    else:
        indexnpb1 = i
        break
#print(score0)
#print(len(npb1[indexnpb1: ]))
score1 = 2**(len(npb1[indexnpb1:]))
scores = score0 * score1
print(scores)



#笔试题目##360公司#
全部评论

相关推荐

看网上风评也太差了
投递万得信息等公司8个岗位 >
点赞 评论 收藏
转发
投递华为等公司10个岗位
点赞 评论 收藏
转发
1 收藏 评论
分享
牛客网
牛客企业服务