0
点赞
收藏
分享

微信扫一扫

leetcodeLCCUP:1. 宝石补给【简单模拟】

天天天蓝loveyou 2022-04-17 阅读 19
python

在这里插入图片描述

分析

每个人有初始的宝石
然后x给y它宝石的一半
求最后最多宝石和最小宝石的差

ac code

class Solution:
    def giveGem(self, gem: List[int], operations: List[List[int]]) -> int:
        for op in operations:
            x, y = op
            give = gem[x] // 2
            gem[x] -= give
            gem[y] += give
        return max(gem) - min(gem)

总结

我爱模拟
简单的那种

举报

相关推荐

0 条评论