116942024-11-05 22:15:4442Osztozkodás (75 pont)python3Accepted 75/75206ms15532 KiB
I,R=input,range
n,k=map(int,I().split())
A=[*map(int,I().split())]
A.sort(reverse=1)
a=b=0
for i in R(n-k):
 if i%2==0:a+=A[i]
 else:b+=A[i]
x=[0]*k
x[-1]=A[-1]
for i in R(1,k):x[-1-i]=x[-i]+A[-1-i]
for i in R(k):
 if x[i]>A[n-k+i]:
  if (n-k-i)%2==0:a+=x[i]
  else:b+=x[i]
  break
 else:
  if (n-k-i)%2==0:a+=A[n-k+i]
  else:b+=A[n-k+i]
print(a,b)
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/016ms3148 KiB
2Accepted0/017ms3056 KiB
3Accepted2/217ms3128 KiB
4Accepted3/316ms3132 KiB
5Accepted3/317ms3148 KiB
6Accepted2/217ms3216 KiB
7Accepted3/319ms3508 KiB
8Accepted2/218ms3388 KiB
9Accepted3/317ms3388 KiB
10Accepted2/217ms3460 KiB
11Accepted3/318ms3388 KiB
12Accepted1/1107ms15072 KiB
13Accepted2/2112ms15196 KiB
14Accepted1/1105ms15200 KiB
15Accepted2/2115ms15284 KiB
16Accepted1/197ms14052 KiB
17Accepted2/2100ms15184 KiB
18Accepted1/193ms13884 KiB
19Accepted2/263ms12104 KiB
20Accepted2/261ms12216 KiB
21Accepted3/3103ms15384 KiB
22Accepted2/2101ms15532 KiB
23Accepted3/3107ms15276 KiB
24Accepted2/2101ms15288 KiB
25Accepted3/3105ms15448 KiB
26Accepted2/2112ms15380 KiB
27Accepted3/3143ms15376 KiB
28Accepted2/2206ms15372 KiB
29Accepted3/3108ms15204 KiB
30Accepted3/316ms3128 KiB
31Accepted3/317ms3128 KiB
32Accepted3/316ms3128 KiB
33Accepted3/316ms3128 KiB
34Accepted3/317ms3128 KiB