/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 14ms 2.988 MiB
#2 Wrong Answer 15ms 3.066 MiB
#3 Wrong Answer 15ms 2.871 MiB
#4 Wrong Answer 15ms 3.027 MiB
#5 Wrong Answer 15ms 3.105 MiB
#6 Wrong Answer 15ms 3.098 MiB
#7 Wrong Answer 15ms 2.984 MiB
#8 Wrong Answer 15ms 3.125 MiB
#9 Wrong Answer 15ms 3.066 MiB
#10 Wrong Answer 14ms 2.934 MiB
#11 Wrong Answer 14ms 3.121 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-10-03 13:59:54
Judged By
Score
0
Total Time
15ms
Peak Memory
3.125 MiB