/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 16ms 3.07 MiB
#2 Accepted 16ms 3.02 MiB
#3 Accepted 14ms 3.121 MiB
#4 Accepted 14ms 3.094 MiB

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-10-03 16:01:48
Judged By
Score
100
Total Time
16ms
Peak Memory
3.121 MiB