Viacheslav_Shevcenko

Ukraine
рд╢рд╛рдорд┐рд▓ рд╣реБрдЖ 24 рд╕рд┐рддре░ 2023
рд╕рдорд╕реНрдпрд╛рдПрдБ21
рд╕рдмрдорд┐рд╢рди23

Andremaxico How did you manage to get such results? Maybe you misunderstood the problem. Here are a few possible outcomes in the example:
Selling first, second, third, then fourth ticket respectively: max(2 - 0, 0) * 37 + max(3 - 1, 0) * 45 + max(1 - 2, 0) * 46 + max(4 - 3, 0) * 30 = 194
Selling fourth, third, second, then first ticket respectively:max(4 - 0, 0) * 30 + max(1 - 1, 0) * 46 + max(3 - 2, 0) * 45 + max(2 - 3, 0) * 37 = 165
Selling second, first, fourth, then third ticket respectively(the maximum possible result):max(3 - 0, 0) * 45 + max(2 - 1, 0) * 37 + max(4 - 2, 0) * 30 + max(1 - 3, 0) * 46 = 232