結果

問題 No.2890 Chiffon
ユーザー 👑 seekworserseekworser
提出日時 2024-07-05 14:35:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 153 ms / 2,000 ms
コード長 708 bytes
コンパイル時間 249 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 155,172 KB
最終ジャッジ日時 2024-07-06 11:13:19
合計ジャッジ時間 5,535 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,116 KB
testcase_01 AC 37 ms
52,488 KB
testcase_02 AC 38 ms
52,116 KB
testcase_03 AC 38 ms
54,028 KB
testcase_04 AC 37 ms
53,384 KB
testcase_05 AC 38 ms
52,520 KB
testcase_06 AC 38 ms
52,616 KB
testcase_07 AC 38 ms
52,988 KB
testcase_08 AC 38 ms
52,772 KB
testcase_09 AC 38 ms
53,968 KB
testcase_10 AC 38 ms
52,568 KB
testcase_11 AC 38 ms
52,064 KB
testcase_12 AC 39 ms
52,068 KB
testcase_13 AC 39 ms
52,776 KB
testcase_14 AC 38 ms
53,788 KB
testcase_15 AC 39 ms
52,460 KB
testcase_16 AC 39 ms
52,616 KB
testcase_17 AC 39 ms
53,868 KB
testcase_18 AC 38 ms
53,052 KB
testcase_19 AC 37 ms
51,944 KB
testcase_20 AC 38 ms
52,732 KB
testcase_21 AC 37 ms
52,388 KB
testcase_22 AC 153 ms
155,172 KB
testcase_23 AC 43 ms
59,752 KB
testcase_24 AC 42 ms
59,028 KB
testcase_25 AC 42 ms
59,516 KB
testcase_26 AC 47 ms
62,160 KB
testcase_27 AC 37 ms
52,560 KB
testcase_28 AC 42 ms
58,708 KB
testcase_29 AC 46 ms
59,788 KB
testcase_30 AC 48 ms
61,516 KB
testcase_31 AC 46 ms
61,872 KB
testcase_32 AC 46 ms
60,704 KB
testcase_33 AC 89 ms
107,404 KB
testcase_34 AC 89 ms
108,264 KB
testcase_35 AC 88 ms
107,408 KB
testcase_36 AC 88 ms
106,988 KB
testcase_37 AC 89 ms
107,588 KB
testcase_38 AC 89 ms
107,660 KB
testcase_39 AC 90 ms
107,456 KB
testcase_40 AC 91 ms
107,052 KB
testcase_41 AC 90 ms
107,468 KB
testcase_42 AC 89 ms
108,004 KB
testcase_43 AC 93 ms
108,644 KB
testcase_44 AC 93 ms
107,844 KB
testcase_45 AC 92 ms
108,208 KB
testcase_46 AC 92 ms
108,284 KB
testcase_47 AC 92 ms
108,688 KB
testcase_48 AC 93 ms
108,164 KB
testcase_49 AC 92 ms
107,540 KB
testcase_50 AC 92 ms
107,548 KB
testcase_51 AC 92 ms
107,676 KB
testcase_52 AC 92 ms
107,616 KB
testcase_53 AC 86 ms
74,324 KB
testcase_54 AC 73 ms
90,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,k = map(int, input().split())
a = list(map(int, input().split()))
a.append(a[0] + 2*n)

p = 0
mn = 2*n
for i in range(k):
    if mn > a[i+1] - a[i]:
        p = i
        mn = a[i+1] - a[i]

an = [0] * (k)
for i in range(k):
    an[i] = (a[(p+i) % k] - a[p]) % (2*n)
an.append(2*n)

ans = 0
for s in range(1, an[1], 2):
    ok = 0
    ng = n
    while ng - ok > 1:
        mid = (ok + ng) // 2
        def check():
            x = 2*mid
            si = s
            for i in range(k-1):
                if si + x > an[i+2]: return False
                si = max(si+x, an[i+1]+1)
            return si + x <= s + 2*n
        if check(): ok = mid
        else: ng = mid
    ans = max(ans, ok*2)
print(ans)
0