20241203 ◎

I want to eat something sweet..

2042A. Greedy Monocarp - 800

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

    a.sort(reverse=True)
    tmp_sum: int = 0
    for ai in a:
        if tmp_sum + ai > k:
            break
        tmp_sum += ai
    print(k - tmp_sum)

2042B. Game with Colored Mables - 1000

Alice: Maximize the number of unique marbles Bob: Minimize the number of unique marbles taken by Alice

For non-unique marbles, Bob is always able take one of them to prevent Alice from getting bonus points

from collections import defaultdict


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

    d = defaultdict(int)
    for ci in c:
        d[ci] += 1

    colors = len(set(c))
    unique = len([color for color, count in d.items() if count == 1])
    print(colors + unique - (unique // 2) * 2)

2042C. Competitive Fishing - 1100

Educational Codeforces Round 172 - Editorial

The solution makes sense, but I don’t think I can solve this problem next time. I don’t think I can replicate the mathematical operations for now.

However, denoting Si as the score of i, i + 1, ..., n - 1, n and constructing a (sort of) sum array seem to be a good approach to remember.

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

    vals: list[int] = []
    _sum = 0
    for i in range(n - 1, 0, -1):
        _sum += 1 if s[i] == "1" else -1
        if _sum > 0:
            vals.append(_sum)

    vals.sort()
    ans: int = 1
    while k > 0 and vals:
        k -= vals.pop()
        ans += 1

    if k > 0:
        print(-1)
    else:
        print(ans)

160.4 lb

Protein shake 50 g Protein chips 15 g Ice cream 0 g Fruits 0 g Yogurt 20 g Tofu 35 g Tuna salad 60 g

total protein -> 180 g (>= 140)

35 minutes run (hard), shoulder press


MUST:


index 20241202 20241204