Accepted
Code
def min_operations_to_zero(N):
dp = [float('inf')] * (N + 1)
dp[0] = 0
for i in range(1, N + 1):
if i >= 2:
dp[i] = min(dp[i], dp[i - 2] + 1)
if i >= 3:
dp[i] = min(dp[i], dp[i - 3] + 1)
return dp[N]
N = int(input())
print(min_operations_to_zero(N))
Information
- Submit By
- Type
- Submission
- Problem
- P1106 too easy or three easy
- Contest
- Brain Booster #6
- Language
- Python 3 (Python 3.12.3)
- Submit At
- 2024-10-03 16:01:48
- Judged At
- 2024-11-11 02:49:27
- Judged By
- Score
- 100
- Total Time
- 15ms
- Peak Memory
- 3.062 MiB