109762024-04-25 14:56:44WellLeopardUsuallyDarabolás (50 pont)python3Accepted 50/50108ms43968 KiB
M,N = map(int,input().split())
sor = list(map(int,input().split()))
oszlop = list(map(int,input().split()))
rang_sor = [0] * 10001
rang_oszlop = [0] * 10001
for x in sor:
    rang_sor[x] += 1
for x in oszlop:
    rang_oszlop[x] += 1
v_vagas = 0
f_vagas = 0
koltseg = 0
for i in range(10000,0,-1):
    if rang_sor[i] > 0:
        koltseg += i * rang_sor[i] * (v_vagas+1)
        f_vagas += rang_sor[i]
        #print("V",i,koltseg)
    if rang_oszlop[i] > 0:
        koltseg += i * rang_oszlop[i] * (f_vagas+1)
        v_vagas += rang_oszlop[i]
        #print("F",i,koltseg)
print(koltseg)
SubtaskSumTestVerdictTimeMemory
base50/50
1Accepted0/020ms11396 KiB
2Accepted0/076ms34044 KiB
3Accepted1/120ms11920 KiB
4Accepted1/119ms11824 KiB
5Accepted1/119ms12180 KiB
6Accepted1/119ms11912 KiB
7Accepted1/119ms12420 KiB
8Accepted1/120ms12764 KiB
9Accepted1/120ms12844 KiB
10Accepted1/120ms13048 KiB
11Accepted1/120ms13076 KiB
12Accepted1/120ms13092 KiB
13Accepted1/119ms13012 KiB
14Accepted1/120ms13340 KiB
15Accepted1/120ms13528 KiB
16Accepted1/120ms13360 KiB
17Accepted1/120ms13852 KiB
18Accepted1/120ms13612 KiB
19Accepted2/221ms13732 KiB
20Accepted2/220ms13732 KiB
21Accepted3/329ms15040 KiB
22Accepted3/334ms16448 KiB
23Accepted4/448ms25580 KiB
24Accepted4/448ms24512 KiB
25Accepted4/472ms37876 KiB
26Accepted4/472ms36048 KiB
27Accepted4/4108ms43912 KiB
28Accepted4/4108ms43968 KiB