Submission #44273437


Source Code Expand

import math
import collections
import heapq

N = int(input())
A = list(map(int, input().split(' ')))

mid = sum(A) / len(A)
low = int(math.floor(mid))
high = int(math.ceil(mid))

plus = 0
minus = 0
count = 0

for a in A:
    if a < mid:
        plus += abs(low - a)
    else:
        minus += abs(a - high)

print(max(plus, minus))

Submission Info

Submission Time
Task C - Approximate Equalization 2
User cocodrips
Language PyPy3 (7.3.0)
Score 400
Code Size 354 Byte
Status AC
Exec Time 145 ms
Memory 101008 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 30
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 02_random2_00.txt, 02_random2_01.txt, 02_random2_02.txt, 02_random2_03.txt, 02_random2_04.txt, 02_random2_05.txt, 02_random2_06.txt, 02_random2_07.txt, 03_handmade_00.txt, 03_handmade_01.txt, 03_handmade_02.txt, 03_handmade_03.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 145 ms 64792 KiB
00_sample_01.txt AC 52 ms 64708 KiB
00_sample_02.txt AC 54 ms 65124 KiB
01_random_00.txt AC 53 ms 64996 KiB
01_random_01.txt AC 50 ms 64828 KiB
01_random_02.txt AC 108 ms 100424 KiB
01_random_03.txt AC 102 ms 100240 KiB
01_random_04.txt AC 106 ms 100564 KiB
01_random_05.txt AC 104 ms 100496 KiB
01_random_06.txt AC 102 ms 100624 KiB
01_random_07.txt AC 107 ms 100748 KiB
01_random_08.txt AC 105 ms 100368 KiB
01_random_09.txt AC 101 ms 100352 KiB
01_random_10.txt AC 102 ms 100384 KiB
01_random_11.txt AC 103 ms 100356 KiB
01_random_12.txt AC 105 ms 100364 KiB
01_random_13.txt AC 104 ms 100356 KiB
01_random_14.txt AC 104 ms 100224 KiB
02_random2_00.txt AC 98 ms 96028 KiB
02_random2_01.txt AC 100 ms 96120 KiB
02_random2_02.txt AC 102 ms 99896 KiB
02_random2_03.txt AC 93 ms 93448 KiB
02_random2_04.txt AC 88 ms 91788 KiB
02_random2_05.txt AC 97 ms 96588 KiB
02_random2_06.txt AC 91 ms 91088 KiB
02_random2_07.txt AC 92 ms 93012 KiB
03_handmade_00.txt AC 102 ms 101008 KiB
03_handmade_01.txt AC 56 ms 64992 KiB
03_handmade_02.txt AC 84 ms 90448 KiB
03_handmade_03.txt AC 53 ms 64772 KiB