Submission #18756488


Source Code Expand

N, M = map(int, input().split())

A = list(map(int, input().split()))
if M == 0:
    print(1)
    exit()
A.sort()
B = [0] * (M + 1)

mn = 10 ** 10
mx = 0
B[0] = A[0] - 1
if B[0] > 0:
    mn = min(B[0], mn)
    mx = max(mx, B[0])
for i in range(M - 1):
    B[i + 1] = A[i + 1] - A[i] - 1
    if  B[i + 1] > 0:
        mn = min(B[i + 1], mn)
        mx = max(mx, B[i + 1])
B[-1] = N - A[-1]
if B[-1] > 0:
    mn = min(B[-1], mn)
    mx = max(mx, B[-1])


def calc(K):
    res = 0
    for i in B:
        if i:
            if K > i:
                return -1
            res += (i + K - 1) // K
    return res


ans = N

if mn == 10 ** 10 and mx == 0:
    print(0)
    exit()

for i in range(mn, mx + 1):
    count = calc(i)
    if count >= 1:
        ans = min(ans, count)

print(ans)

Submission Info

Submission Time
Task D - Stamp
User noyan
Language PyPy3 (7.3.0)
Score 400
Code Size 831 Byte
Status AC
Exec Time 1343 ms
Memory 93632 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 4
AC × 30
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All handmade_00.txt, handmade_01.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, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
handmade_00.txt AC 62 ms 61684 KiB
handmade_01.txt AC 49 ms 61824 KiB
random_00.txt AC 52 ms 61680 KiB
random_01.txt AC 346 ms 63780 KiB
random_02.txt AC 114 ms 86364 KiB
random_03.txt AC 138 ms 93504 KiB
random_04.txt AC 47 ms 61696 KiB
random_05.txt AC 109 ms 85556 KiB
random_06.txt AC 139 ms 93560 KiB
random_07.txt AC 482 ms 63836 KiB
random_08.txt AC 52 ms 61704 KiB
random_09.txt AC 125 ms 91544 KiB
random_10.txt AC 1343 ms 67728 KiB
random_11.txt AC 115 ms 84700 KiB
random_12.txt AC 49 ms 61960 KiB
random_13.txt AC 62 ms 67544 KiB
random_14.txt AC 121 ms 88744 KiB
random_15.txt AC 112 ms 89132 KiB
random_16.txt AC 49 ms 61732 KiB
random_17.txt AC 62 ms 68016 KiB
random_18.txt AC 137 ms 93632 KiB
random_19.txt AC 53 ms 63820 KiB
random_20.txt AC 49 ms 61960 KiB
random_21.txt AC 61 ms 69556 KiB
random_22.txt AC 426 ms 67548 KiB
random_23.txt AC 64 ms 67940 KiB
sample_01.txt AC 51 ms 62004 KiB
sample_02.txt AC 49 ms 61912 KiB
sample_03.txt AC 48 ms 61860 KiB
sample_04.txt AC 50 ms 61868 KiB