85202024-01-20 10:59:06baktucsokPontos átlag 2python3Time limit exceeded 10/1002.099s57468 KiB
import sys
import math
db, ar = list(map(int, input().strip().split()))
y = list(map(int, input().strip().split()))
s = sum(y)
Z=0
a = 0
m = min(y)
b=0
if s < ar*db:
    print(math.ceil((ar*db-s)/db))
elif s == ar*db:
    print(0)
else:
    if min(y) > math.ceil((s-ar*db)/db):
        print(math.ceil((s-ar*db)/db))
    else:
        while s-b+m*len(y)> ar*db and len(y)>1:
            m= min(y)

            Z+=(m-1)
            for i in range(len(y)):
                y[i]-= (m-1)
            b+=(len(y)*(m-1))
            for i in range(y.count(1)):
                y.remove(1)
        while s-a-b > db*ar:
            for i in range(len(y)):
                if y[i] > 1:
                    y[i]-=1
                    a+=1
            Z+=1
        print(Z)

        


        
sys.stdout.close()
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted19ms11432 KiB
2Accepted19ms11504 KiB
subtask210/10
3Accepted17ms11920 KiB
4Accepted17ms12328 KiB
5Accepted18ms12304 KiB
6Accepted17ms12664 KiB
7Accepted17ms12476 KiB
8Accepted17ms12848 KiB
subtask30/20
9Accepted59ms20620 KiB
10Time limit exceeded2.059s9324 KiB
11Accepted57ms19764 KiB
12Time limit exceeded2.075s9052 KiB
13Accepted59ms20988 KiB
14Time limit exceeded2.075s9596 KiB
15Time limit exceeded2.068s9428 KiB
16Time limit exceeded2.048s9660 KiB
17Accepted18ms13428 KiB
subtask40/24
18Wrong answer86ms13560 KiB
19Wrong answer104ms13592 KiB
20Wrong answer32ms13792 KiB
21Wrong answer146ms13732 KiB
22Wrong answer128ms13796 KiB
23Accepted17ms13624 KiB
24Accepted17ms13688 KiB
25Accepted17ms13916 KiB
26Wrong answer57ms14104 KiB
27Wrong answer74ms13904 KiB
28Accepted18ms14060 KiB
subtask50/46
29Time limit exceeded2.099s10004 KiB
30Time limit exceeded2.056s28876 KiB
31Time limit exceeded2.079s19204 KiB
32Accepted78ms49780 KiB
33Time limit exceeded2.052s28268 KiB
34Time limit exceeded2.076s28160 KiB
35Accepted93ms57468 KiB
36Time limit exceeded2.065s28412 KiB
37Time limit exceeded2.072s28236 KiB
38Accepted92ms57016 KiB
39Time limit exceeded2.088s14224 KiB
40Wrong answer1.958s15356 KiB
41Accepted17ms14720 KiB