题解 | 田忌赛马

田忌赛马

https://www.nowcoder.com/practice/49d799f65a0749588e9cd7e6135a4a9a

有趣的思维题,排序后遍历一遍田忌的马即可,贪心算法,始终让刚好能跑赢齐王的马上场:)

l1 = list(sorted(list(map(int,input().split()))))
l2 = list(sorted(list(map(int,input().split()))))
cnt = 0
for i in range(3):
    if l2[i] > l1[cnt]:
        cnt += 1
print("Yes" if cnt >= 2 else "No")

全部评论
牛皮
1 回复 分享
发布于 01-26 19:38 香港
这个解法优点像看透先机
点赞 回复 分享
发布于 04-02 15:07 广东

相关推荐

明明就不饿:看不懂你到底会啥,什么岗位
点赞 评论 收藏
分享
评论
33
2
分享

创作者周榜

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