Submission #70445546


Source Code Expand

n, m, c = map(int, input().split())
A = list(map(int, input().split()))
from itertools import accumulate

AS = sorted(set(A)|{-m+max(A)})
I = {a:i for i, a in enumerate(AS)}
num = len(I)
B = [0]*num
for a in A:
  B[I[a]] += 1

B += B
B = list(accumulate(B))

# print(AS)
ans = 0
import bisect
for i in range(1, num):
  idx = bisect.bisect_left(B, c+B[i-1])
  ans += (B[idx]-B[i-1])*(AS[i]-AS[i-1])

print(ans)

Submission Info

Submission Time
Task D - On AtCoder Conference
User uparupaaa
Language Python (PyPy 3.10-v7.3.12)
Score 425
Code Size 432 Byte
Status AC
Exec Time 496 ms
Memory 311148 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 425 / 425
Status
AC × 2
AC × 32
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt
Case Name Status Exec Time Memory
example_00.txt AC 58 ms 76508 KiB
example_01.txt AC 58 ms 76496 KiB
hand_00.txt AC 133 ms 161904 KiB
hand_01.txt AC 133 ms 162340 KiB
hand_02.txt AC 496 ms 311148 KiB
hand_03.txt AC 113 ms 157556 KiB
hand_04.txt AC 58 ms 76568 KiB
hand_05.txt AC 58 ms 76476 KiB
random_00.txt AC 125 ms 138928 KiB
random_01.txt AC 128 ms 138992 KiB
random_02.txt AC 134 ms 138892 KiB
random_03.txt AC 162 ms 159572 KiB
random_04.txt AC 174 ms 171012 KiB
random_05.txt AC 166 ms 160924 KiB
random_06.txt AC 347 ms 305200 KiB
random_07.txt AC 332 ms 304632 KiB
random_08.txt AC 325 ms 288756 KiB
random_09.txt AC 142 ms 160388 KiB
random_10.txt AC 137 ms 162092 KiB
random_11.txt AC 151 ms 160708 KiB
random_12.txt AC 143 ms 159944 KiB
random_13.txt AC 162 ms 180864 KiB
random_14.txt AC 141 ms 161700 KiB
random_15.txt AC 161 ms 181608 KiB
random_16.txt AC 160 ms 181472 KiB
random_17.txt AC 165 ms 180800 KiB
random_18.txt AC 184 ms 193268 KiB
random_19.txt AC 188 ms 193712 KiB
random_20.txt AC 184 ms 190588 KiB
random_21.txt AC 363 ms 263524 KiB
random_22.txt AC 351 ms 266020 KiB
random_23.txt AC 484 ms 300724 KiB