⌨️

[AtCoder]ABC-074|B - Collecting Balls (Easy Version)

2023/01/04に公開約400字

設問ページ

提出結果

def getInt():
    return int(input())


def getIntList():
    return list(map(int, input().split()))


def main():
    n = getInt()
    k = getInt()
    x = getIntList()

    r = 0
    for i in range(n):
        r += (x[i] if x[i] * 2 < k else (k - x[i])) * 2
    print(r)


if __name__ == "__main__":
    main()

Discussion

ログインするとコメントできます