200972026-01-01 19:43:47herczegkatÚthasználati díj (75 pont)python3Accepted 75/7552ms4980 KiB
'''
10 3
0 1 1 0 0 0 1 1 0 1

5 5
0 1 0 0 0
'''

varosDB, penz=[int(i) for i in input().split()]
dijDB=0
utakL=[int(i) for i in input().split()]
for i in range(varosDB):
    dijDB+=utakL[i]
mx=penz-1
if dijDB<penz: mx=dijDB-1
lehetoseg=int((dijDB-mx)*mx + (mx-1)*mx/2	)
# lehetoseg=(dijDB-mx-1)*mx+mx*(mx+1)/2
print(lehetoseg)
      





    
    
SubtaskSumTestVerdictTimeMemory
base75/75
1Accepted0/016ms2928 KiB
2Accepted0/016ms2864 KiB
3Accepted0/050ms4832 KiB
4Accepted5/516ms2924 KiB
5Accepted5/516ms2872 KiB
6Accepted5/516ms2868 KiB
7Accepted5/516ms2868 KiB
8Accepted5/516ms2868 KiB
9Accepted5/517ms2992 KiB
10Accepted5/517ms3104 KiB
11Accepted5/516ms2996 KiB
12Accepted5/517ms2876 KiB
13Accepted5/516ms3072 KiB
14Accepted5/550ms4908 KiB
15Accepted5/552ms4980 KiB
16Accepted5/552ms4848 KiB
17Accepted5/550ms4904 KiB
18Accepted5/550ms4964 KiB