157792025-02-26 18:23:31MangoOsztozkodás (75 pont)python3Runtime error 0/7517ms3324 KiB
a = int(input()) 
v = int(input())
e = 0
m = 0
tsz = 0
mx = 0
mxx = 0
h = 0
aé = input()
aé = aé.split()
for i in range(a):
    aé[i] = int(aé[i])

for j in range(a):
    h += aé[j]

mxxx = max(aé)

for i in range(a):
    if i + 1 == v:
        if tsz == 0:
            e = h - m
        else:
            m = h - e
    else:
        if tsz == 0:
            for f in range(a - (i + 1)):
                if aé[f] > mx:
                    mx = aé[f]
                    if mxxx == mx:
                        e += mxx
                        mxxx = mxx
                        tsz = 1
                    else:
                        mxx = aé[f]
        else:
            for g in range(a - (i + 1)):
                if aé[g] > mx:
                    mx = aé[g]
                    if mxxx == mx:
                        m += mxx
                        mxxx = mxx
                        tsz = 0
                    else:
                        mxx = aé[g]

print (m,e)
                    



 
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/016ms3316 KiB
2Runtime error0/016ms3124 KiB
3Runtime error0/216ms3324 KiB
4Runtime error0/316ms3320 KiB
5Runtime error0/317ms2972 KiB
6Runtime error0/216ms2996 KiB
7Runtime error0/316ms3192 KiB
8Runtime error0/216ms3196 KiB
9Runtime error0/316ms3132 KiB
10Runtime error0/216ms3124 KiB
11Runtime error0/316ms3120 KiB
12Runtime error0/116ms2988 KiB
13Runtime error0/216ms3124 KiB
14Runtime error0/117ms3140 KiB
15Runtime error0/216ms3112 KiB
16Runtime error0/116ms3124 KiB
17Runtime error0/217ms3128 KiB
18Runtime error0/116ms3124 KiB
19Runtime error0/216ms2992 KiB
20Runtime error0/216ms3192 KiB
21Runtime error0/316ms3136 KiB
22Runtime error0/216ms3108 KiB
23Runtime error0/316ms3188 KiB
24Runtime error0/216ms3136 KiB
25Runtime error0/316ms3124 KiB
26Runtime error0/216ms3124 KiB
27Runtime error0/316ms3200 KiB
28Runtime error0/217ms3204 KiB
29Runtime error0/316ms3204 KiB
30Runtime error0/316ms3144 KiB
31Runtime error0/316ms3188 KiB
32Runtime error0/314ms3152 KiB
33Runtime error0/316ms3312 KiB
34Runtime error0/316ms3320 KiB