20240806

Retry: 1993C. Light Switches

I could not solve this problem during the contest, but after some struggle, I managed to pass the tests.

from collections import defaultdict


for _ in range(int(input())):
    n, k = map(int, input().split())
    a: list[int] = list(map(int, input().split()))

    amax: int = max(a)
    amod: list[int] = [x + (amax - x) // (2 * k) * (2 * k) for x in a]
    amod = [x + 2 * k if amax - x > k else x for x in amod]
    amodmax = max(amod)
    amodmin = min(amod)
    if amodmax - amodmin < k:
        print(amodmax)
    else:
        print(-1)

Ketone 5 mg/dl

Salad 30g Protein shake 10g

Total carbohydrate 40 g


MUST:

TODO:


index 20240805 20240807