/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 15ms 3.047 MiB
#2 Wrong Answer 15ms 3.125 MiB

Code

def can_get_coins(X, a, b, c, N):
    # Calculate the maximum number of coins Alice can bear
    max_bearable_coins = X + N

    # Check if it's possible to get exactly N coins using the spells
    if N <= X or (a == b == c == 1 and max_bearable_coins >= N):
        return "YES", 0

    # Find the minimum number of operations needed to get exactly N coins
    min_operations = min((N - X) % a, (N - X) % b, (N - X) % c)

    return "YES", min_operations

def main():
    X, a, b, c, N = map(int, input().split())
    result, min_operations = can_get_coins(X, a, b, c, N)
    
    print(result)
    if result == "YES":
        print(min_operations)

if __name__ == "__main__":
    main()

Information

Submit By
Type
Submission
Problem
P1028 Magical box and spell
Contest
Brain booster #2
Language
Python 3 (Python 3.12.3)
Submit At
2024-03-06 16:52:10
Judged At
2024-11-11 03:41:10
Judged By
Score
0
Total Time
15ms
Peak Memory
3.125 MiB