200502025-12-31 11:45:02marnorlorOsztozkodás (75 pont)python3Runtime error 0/7517ms3360 KiB
def osztozas(N: int, K: int, A: list):
    ajandekA=[]
    ajandekB=[]
    max2=0
    kOsszeg=0
    osszegA=0
    osszegB=0
    for j in range(0, len(A)+1):
        A.sort(reverse=True)
        max2=A[0]
        if len(A)<=K:
            for i in A:
                kOsszeg=kOsszeg+i
        if kOsszeg<max2:
            if j % 2==0:
                ajandekA.append(max2)
                osszegA=osszegA+max2
            if j % 2==1:
                ajandekB.append(max2)
                osszegB=osszegB+max2
            A.remove(max2)
        else:
            A=[]
            if j % 2==0:
                ajandekA.append(kOsszeg)
                osszegA=osszegA+kOsszeg
            if j % 2==1:
                ajandekB.append(kOsszeg)
                osszegB=osszegB+kOsszeg
        kOsszeg=0
        max2=0
        if len(A)==0:
            break
    return osszegA, osszegB

def test():
    a, b=osztozas(5, 3, [-2, 3, -1, 4, 5])
    assert 6==a
    assert 3==b

    a, b=osztozas(5, 3, [1, 4, 2, 4, 5])
    print(a, b)
    assert 12==a
    assert 4==b  

def futtatas()
    N, K=map(int,input().split())
    A=list(map(int,input().split()))
    a, b=osztozas(N, K, A)
    print(a, b)

#test()
futtatas()
SubtaskSumTestVerdictTimeMemory
base0/75
1Runtime error0/016ms3320 KiB
2Runtime error0/016ms3124 KiB
3Runtime error0/214ms3148 KiB
4Runtime error0/316ms3120 KiB
5Runtime error0/316ms3148 KiB
6Runtime error0/217ms2972 KiB
7Runtime error0/316ms3052 KiB
8Runtime error0/216ms3060 KiB
9Runtime error0/317ms3160 KiB
10Runtime error0/216ms3116 KiB
11Runtime error0/316ms3004 KiB
12Runtime error0/116ms3168 KiB
13Runtime error0/216ms3128 KiB
14Runtime error0/117ms3176 KiB
15Runtime error0/216ms3120 KiB
16Runtime error0/116ms3360 KiB
17Runtime error0/216ms3140 KiB
18Runtime error0/116ms3148 KiB
19Runtime error0/216ms3124 KiB
20Runtime error0/216ms3124 KiB
21Runtime error0/316ms3124 KiB
22Runtime error0/216ms3008 KiB
23Runtime error0/316ms3016 KiB
24Runtime error0/216ms3044 KiB
25Runtime error0/316ms3124 KiB
26Runtime error0/216ms3144 KiB
27Runtime error0/316ms3124 KiB
28Runtime error0/217ms2948 KiB
29Runtime error0/317ms3120 KiB
30Runtime error0/317ms3332 KiB
31Runtime error0/317ms3120 KiB
32Runtime error0/316ms3124 KiB
33Runtime error0/316ms2992 KiB
34Runtime error0/316ms3072 KiB