20240805

Review: 1993A. Question Marks

For every option, n score can be obtained at most.

from collections import defaultdict


for _ in range(int(input())):
    n: int = int(input())
    s: list[str] = list(input())

    d: defaultdict = defaultdict(int)
    for x in s:
        d[x] += 1

    score: int = 0
    score += min(d["A"], n)
    score += min(d["B"], n)
    score += min(d["C"], n)
    score += min(d["D"], n)
    print(score)

Review: 1993B. Parity and Sum

Observation:

def solve(n: int, a: list[int]) -> int:
    evens: list[int] = [x for x in a if x % 2 == 0]
    odds: list[int] = [x for x in a if x % 2 == 1]

    if len(evens) == n or len(odds) == n:
        return 0

    evens.sort()
    oddmax: int = max(odds)

    for x in evens:
        if oddmax > x:
            oddmax += x
        else:
            return len(evens) + 1
    return len(evens)


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

    ans: int = solve(n, a)
    print(ans)

Ketone 5 mg/dl

Salad 30g Protein shake 10g

Total carbohydrate 40 g


MUST:

TODO:


index 20240804 20240806