Algorithm/boj

[파이썬] 13560 축구 게임

takeU 2022. 6. 19. 14:26
반응형
n = int(input())
li = sorted(list(map(int, input().split())))

def check():
    s = 0
    if sum(li) != n * (n - 1) // 2:
        return -1
    for i, l in enumerate(li[:-1]):
        s += l
        if s < i * (i + 1) // 2:
            return -1
    return 1

print(check())

수학

tournament graph