/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 14ms 3.09 MiB
#2 Wrong Answer 14ms 2.977 MiB
#3 Wrong Answer 14ms 3.098 MiB
#4 Wrong Answer 14ms 3.031 MiB
#5 Wrong Answer 14ms 3.012 MiB
#6 Wrong Answer 14ms 3.102 MiB
#7 Wrong Answer 14ms 3.125 MiB
#8 Wrong Answer 14ms 2.938 MiB
#9 Wrong Answer 14ms 2.984 MiB
#10 Wrong Answer 14ms 3.082 MiB
#11 Wrong Answer 14ms 3.082 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 % a, N % b, N % 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:51:05
Judged At
2024-10-03 13:59:55
Judged By
Score
0
Total Time
14ms
Peak Memory
3.125 MiB