Problem: We have A cards, each of which has an integer 1 written on it. Similarly, we also have B cards with 0s and C cards with -1s.  We will pick up K among these cards. What is the maximum possible sum of the numbers written on the cards chosen?

Submission attempts (in order):
A, B, C, K = map(int, input().split())
if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
elif (A + B + C) > K:
    print(A - (K - A - B)
elif (A + B + C) == K:
    print(A - C)

A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(K)
elif (A + B) >= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)


A, B, C, K = map(int, input().split())
result = 0

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    if (A + B + C) > K:
        print(A - (K - (A + B))
    elif (A + B + C) <= K:
        print(A - C)

A, B, C, K = map(int, input().split())
result = 0
p

if A >= K:
    print(A)
elif (A + B) >= K:
    print(A)
else:
    for i in range(K):
        print(i)
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            continue
        elif B == (i + 1 - A):
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)

A, B, C, K = map(int, input().split())
result = 0

for i in range(K):
    if A > (i + 1):
        result += 1
    elif A == (i + 1):
        result += 1
        continue
    else:
        break

    if B > (i + 1 - A):
        result += 0
    elif B == (i + 1 - A):
        result += 0
        continue
    else:
        break

    if C > (i + 1 - A - B):
        result -= 1
    elif C == (i + 1 - A - B):
        result -= 1
        break
    else:
        break

print(result)


A, B, C, K = map(int, input().split())
result = 0

if A <= K:
    print(K)
elif (A + B) <= K:
    print(K)
else:
    for i in range(K):
        if A > (i + 1):
            result += 1
            continue
        elif A == (i + 1):
            result += 1
            continue

        if B > (i + 1 - A):
            result += 0
            continue
        elif B == (i + 1 - A):
            result += 0
            continue

        if C > (i + 1 - A - B):
            result -= 1
            continue
        elif C == (i + 1 - A - B):
            result -= 1
            break
        else:
            break
    print(result)


A, B, C, K = map(int, input().split())
if A >= K:
    print(K)
elif (A + B) >= K:
    print(A)
elif (A + B + C) > K:
    print(A - (K - A - B))
elif (A + B + C) == K:
    print(A - C)

Verdicts: Runtime Error

Wrong Answer

Runtime Error

Runtime Error

Wrong Answer

Wrong Answer

Accepted