/ SeriousOJ /

Record Detail

Wrong Answer


  
# Status Time Cost Memory Cost
#1 Wrong Answer 21ms 2.883 MiB
#2 Wrong Answer 21ms 3.039 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-11-11 03:41:11
Judged By
Score
0
Total Time
21ms
Peak Memory
3.039 MiB