/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 16ms 2.996 MiB
#2 Accepted 16ms 3.105 MiB
#3 Accepted 15ms 3.082 MiB
#4 Accepted 16ms 3.129 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-12-17 11:35:33
Judged By
Score
100
Total Time
16ms
Peak Memory
3.129 MiB