99482024-03-20 23:42:4742Vásárlások inflációs hatása (75 pont)python3Accepted 75/7518ms14048 KiB
# O(NlogN)

from sys import stdin
input=stdin.readline

def solv():
    N,K = [int(x) for x in input().split()]
    P = [int(x) for x in input().split()]
    P.sort()
    res=0
    cur=0
    for i in range(N):
        if N-i-1>=K:
            res+=P[i]
        else:
            res+=P[i]+cur
            cur*=2
        cur+=P[i]
            
    print(res)
    
solv()
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/018ms11328 KiB
2Accepted0/018ms11476 KiB
3Accepted1/117ms11584 KiB
4Accepted1/117ms11964 KiB
5Accepted1/117ms11804 KiB
6Accepted1/117ms11872 KiB
7Accepted1/117ms12212 KiB
8Accepted1/117ms12464 KiB
9Accepted1/117ms12416 KiB
10Accepted1/117ms12508 KiB
11Accepted2/217ms12576 KiB
12Accepted5/517ms13108 KiB
13Accepted5/517ms13160 KiB
14Accepted5/518ms13436 KiB
15Accepted5/517ms13320 KiB
16Accepted5/517ms13516 KiB
17Accepted5/517ms13644 KiB
18Accepted5/518ms13744 KiB
19Accepted5/517ms13612 KiB
20Accepted5/517ms13684 KiB
21Accepted5/517ms13632 KiB
22Accepted5/517ms13644 KiB
23Accepted5/517ms14048 KiB
24Accepted5/518ms13824 KiB