Ciao a tutti, ho bisogno di aiuto per risolvere il problema Ping-pong.
Mi sembra di aver gestito tutti i casi possibili eppure sbaglia l’ultimo subtask, cioè quando i set possibili sono più di 4.
Ecco il mio codice:
#!/usr/bin/env python3
# NOTE: it is recommended to use this even if you don't understand the following code.
import sys
import math
# uncomment the two following lines if you want to read/write from files
# sys.stdin = open('input.txt')
# sys.stdout = open('output.txt', 'w')
T = int(input().strip())
for test in range(1, T+1):
A, B = map(int, input().strip().split())
C = -1
D = -1
# INSERT YOUR CODE HERE
extra = A - 33
lost = math.ceil(extra/11)
if 33 <= A <= 53 and B >= lost*11:
# lost
while extra > 0 or B > 30:
C = min(extra, 10)
D = 11
extra -= C
A -= C
B -= D
print(C, D)
# win
while A > 0:
C = 11
D = min(B, 10)
A -= C
B -= D
print(C, D)
else:
print(C, D)
sys.stdout.close()
Grazie mille in anticipo!