20240805
- updated my resume with the sign up feature
- updated my resume with the document structure and AWS S3
- added some more bullet points
- completed updating my resume and asked my wife to review it
- I'm not considering changing jobs at the moment tho
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)
Observation:
- With the given operation, we can only turn even numbers into odd
numbers to meet the condition except for a corner case where all the
elements are even.
- To update a parity, an odd number and an even number smaller than
the odd number must be chosen.
- When the maximum odd number is bigger than an even number, the even
number can be replaced with an odd number in 1 operation.
- Otherwise, the maximum odd number needs to be increased by adding
the even number chosen. And then, the even number can be replaced with a
new odd number. 2 operations in total.
- To avoid the additional operation that does not change parity but
increases the maximum odd number, keep choosing the largest odd number
and the smallest even number.
- Suppose it's not possible to make the temporary most significant odd
onumber larger than even numbers. In that case, the optimal solution is
to choose the largest odd number and the largest even number in the
first operation, creating a new odd number that is larger than all the
evens.
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:
- Clean my keyboard
- DL Renewal (20240812)
- Get a photo for password renewal
index 20240804 20240806