結果

問題 No.2890 Chiffon
ユーザー 👑 rin204rin204
提出日時 2024-09-13 22:03:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 185 ms / 2,000 ms
コード長 632 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 82,512 KB
実行使用メモリ 195,052 KB
最終ジャッジ日時 2024-09-13 22:03:59
合計ジャッジ時間 6,168 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,544 KB
testcase_01 AC 38 ms
53,092 KB
testcase_02 AC 37 ms
52,460 KB
testcase_03 AC 38 ms
53,712 KB
testcase_04 AC 38 ms
52,736 KB
testcase_05 AC 39 ms
53,944 KB
testcase_06 AC 37 ms
52,336 KB
testcase_07 AC 38 ms
52,436 KB
testcase_08 AC 39 ms
52,940 KB
testcase_09 AC 38 ms
52,600 KB
testcase_10 AC 38 ms
52,420 KB
testcase_11 AC 38 ms
53,120 KB
testcase_12 AC 39 ms
52,628 KB
testcase_13 AC 38 ms
52,476 KB
testcase_14 AC 38 ms
51,752 KB
testcase_15 AC 38 ms
53,432 KB
testcase_16 AC 40 ms
52,504 KB
testcase_17 AC 38 ms
52,220 KB
testcase_18 AC 38 ms
52,256 KB
testcase_19 AC 39 ms
52,592 KB
testcase_20 AC 38 ms
52,324 KB
testcase_21 AC 38 ms
53,136 KB
testcase_22 AC 185 ms
195,052 KB
testcase_23 AC 42 ms
59,520 KB
testcase_24 AC 41 ms
58,652 KB
testcase_25 AC 42 ms
59,024 KB
testcase_26 AC 46 ms
61,280 KB
testcase_27 AC 38 ms
52,732 KB
testcase_28 AC 42 ms
58,716 KB
testcase_29 AC 43 ms
60,316 KB
testcase_30 AC 47 ms
61,672 KB
testcase_31 AC 47 ms
61,264 KB
testcase_32 AC 45 ms
60,492 KB
testcase_33 AC 120 ms
152,460 KB
testcase_34 AC 119 ms
151,088 KB
testcase_35 AC 119 ms
151,120 KB
testcase_36 AC 121 ms
151,012 KB
testcase_37 AC 118 ms
151,724 KB
testcase_38 AC 118 ms
150,800 KB
testcase_39 AC 126 ms
153,132 KB
testcase_40 AC 120 ms
151,276 KB
testcase_41 AC 120 ms
153,112 KB
testcase_42 AC 120 ms
152,800 KB
testcase_43 AC 120 ms
149,700 KB
testcase_44 AC 117 ms
149,904 KB
testcase_45 AC 119 ms
151,216 KB
testcase_46 AC 120 ms
151,300 KB
testcase_47 AC 120 ms
151,200 KB
testcase_48 AC 120 ms
150,888 KB
testcase_49 AC 123 ms
150,940 KB
testcase_50 AC 119 ms
151,060 KB
testcase_51 AC 119 ms
151,352 KB
testcase_52 AC 118 ms
151,480 KB
testcase_53 AC 88 ms
75,632 KB
testcase_54 AC 103 ms
116,324 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n, k = map(int, input().split())
A = list(map(int, input().split()))
b = A[-1] - 2 * n
D = []
for a in A:
    D.append(a - b)
    b = a

D = [d // 2 - 1 for d in D]
ans = 1
k = D.index(min(D))
D = D[k:] + D[:k]
ma_d = max(D)
ma = 0
for i in range(D[0] + 1):
    l = 0
    r = ma_d + 1

    def ok(x):
        y = D[0] - i
        for d in D[1:]:
            if y + d < x:
                return False
            y = d - max(0, x - y)

        return y + i >= x

    while r - l > 1:
        mid = (l + r) // 2
        if ok(mid):
            l = mid
        else:
            r = mid

    ma = max(ma, l)

ans += ma
print(ans * 2)
0