結果

問題 No.2890 Chiffon
ユーザー tassei903tassei903
提出日時 2024-09-14 00:26:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,040 KB
実行使用メモリ 154,760 KB
最終ジャッジ日時 2024-09-14 00:26:30
合計ジャッジ時間 5,773 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,348 KB
testcase_01 AC 40 ms
52,696 KB
testcase_02 AC 39 ms
52,468 KB
testcase_03 AC 40 ms
52,480 KB
testcase_04 AC 39 ms
52,404 KB
testcase_05 AC 39 ms
52,128 KB
testcase_06 AC 39 ms
52,984 KB
testcase_07 AC 38 ms
52,972 KB
testcase_08 AC 39 ms
52,768 KB
testcase_09 AC 39 ms
53,008 KB
testcase_10 AC 39 ms
53,096 KB
testcase_11 AC 39 ms
53,280 KB
testcase_12 AC 39 ms
53,112 KB
testcase_13 AC 38 ms
52,768 KB
testcase_14 AC 39 ms
53,068 KB
testcase_15 AC 39 ms
52,828 KB
testcase_16 AC 39 ms
52,216 KB
testcase_17 AC 38 ms
52,820 KB
testcase_18 AC 39 ms
52,560 KB
testcase_19 AC 39 ms
52,500 KB
testcase_20 AC 40 ms
52,208 KB
testcase_21 AC 38 ms
53,100 KB
testcase_22 AC 149 ms
154,760 KB
testcase_23 AC 44 ms
61,588 KB
testcase_24 AC 42 ms
59,452 KB
testcase_25 AC 43 ms
59,192 KB
testcase_26 AC 50 ms
62,160 KB
testcase_27 AC 38 ms
53,012 KB
testcase_28 AC 44 ms
59,700 KB
testcase_29 AC 46 ms
60,300 KB
testcase_30 AC 50 ms
61,820 KB
testcase_31 AC 49 ms
63,340 KB
testcase_32 AC 45 ms
60,548 KB
testcase_33 AC 89 ms
107,180 KB
testcase_34 AC 90 ms
107,404 KB
testcase_35 AC 88 ms
106,868 KB
testcase_36 AC 88 ms
106,644 KB
testcase_37 AC 89 ms
107,376 KB
testcase_38 AC 88 ms
106,556 KB
testcase_39 AC 88 ms
107,388 KB
testcase_40 AC 91 ms
108,032 KB
testcase_41 AC 91 ms
107,268 KB
testcase_42 AC 91 ms
106,876 KB
testcase_43 AC 92 ms
107,256 KB
testcase_44 AC 88 ms
107,060 KB
testcase_45 AC 88 ms
106,976 KB
testcase_46 AC 88 ms
106,836 KB
testcase_47 AC 89 ms
106,784 KB
testcase_48 AC 92 ms
107,688 KB
testcase_49 AC 91 ms
108,312 KB
testcase_50 AC 91 ms
107,480 KB
testcase_51 AC 89 ms
106,888 KB
testcase_52 AC 89 ms
107,100 KB
testcase_53 AC 54 ms
63,912 KB
testcase_54 AC 74 ms
89,636 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
#######################################################################

n, k = na()

a = na()
f = 10 ** 18
fi = -1
for i in range(k):
    if (a[(i+1) % k] - a[i]) % (2 * n) < f:
        f = (a[(i+1) % k] - a[i]) % (2 * n)
        fi = i

x = a[fi]
a = [(a[i] - x) % (2 * n) // 2 for i in range(k)]
a.sort()
a.append(n)


ok = 1
ng = n + 1
#print(a)
while ng - ok > 1:
    mid = (ok + ng) // 2
    
    FLAG = 0
    for x in range(a[1]):
        y = x
        for i in range(1, k+1):
            y = max(y + mid, a[i])
            if i < k and y >= a[i+1]:
                break
        else:
            #print(mid, x, y)
            if y <= x + n:
                FLAG = 1
            break
    if FLAG:
        ok = mid
    else:
        ng = mid

print(ok * 2)
0