百度测开笔试

第一题:
while True:
    try:
        x,y=map(int,input().split())
        s=input()
        for i in s:
            if i=="U":
                y+=1
            elif i=="D":
                y-=1
            elif i=="L":
                x-=1
            elif i=="R":
                x+=1
        ans=str(x)+" "+str(y)
        print(ans)
    except:break
第二题:
n,m,k=map(int,input().split())
a=[]
for i in range(n):
    a.append(list(map(int,input().split())))
a.sort(key=lambda x:(-x[2],x[0],x[1]))
price=0
weight=0
ans=0
for i in a:
    if price+i[0]<=k and weight+i[1]<=m:
        price+=i[0]
        weight+=i[1]
        ans+=1
    else:
        continue
print(ans)
选择题不记得了,非科班计算机知识的广度不够的劣势让我败在这次笔试选择题中#百度##笔试题型#
全部评论

相关推荐

程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
评论
1
3
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务