結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
ユーザー StanMarshStanMarsh
提出日時 2024-02-23 21:36:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 614 ms / 2,000 ms
コード長 1,199 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 81,956 KB
実行使用メモリ 258,312 KB
最終ジャッジ日時 2024-02-23 21:36:25
合計ジャッジ時間 13,473 ms
ジャッジサーバーID
(参考情報)
judge16 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,716 KB
testcase_01 AC 546 ms
79,144 KB
testcase_02 AC 274 ms
77,496 KB
testcase_03 AC 272 ms
77,512 KB
testcase_04 AC 384 ms
213,464 KB
testcase_05 AC 451 ms
258,044 KB
testcase_06 AC 353 ms
143,124 KB
testcase_07 AC 406 ms
257,020 KB
testcase_08 AC 315 ms
153,804 KB
testcase_09 AC 373 ms
258,312 KB
testcase_10 AC 371 ms
258,284 KB
testcase_11 AC 362 ms
176,404 KB
testcase_12 AC 352 ms
237,988 KB
testcase_13 AC 372 ms
257,864 KB
testcase_14 AC 343 ms
257,404 KB
testcase_15 AC 403 ms
257,404 KB
testcase_16 AC 358 ms
257,280 KB
testcase_17 AC 357 ms
257,404 KB
testcase_18 AC 355 ms
257,404 KB
testcase_19 AC 376 ms
257,404 KB
testcase_20 AC 346 ms
257,404 KB
testcase_21 AC 351 ms
257,404 KB
testcase_22 AC 359 ms
257,404 KB
testcase_23 AC 358 ms
257,404 KB
testcase_24 AC 137 ms
139,260 KB
testcase_25 AC 112 ms
97,624 KB
testcase_26 AC 346 ms
207,356 KB
testcase_27 AC 347 ms
171,420 KB
testcase_28 AC 137 ms
139,244 KB
testcase_29 AC 128 ms
112,628 KB
testcase_30 AC 253 ms
233,836 KB
testcase_31 AC 197 ms
206,956 KB
testcase_32 AC 224 ms
220,652 KB
testcase_33 AC 228 ms
234,040 KB
testcase_34 AC 261 ms
234,348 KB
testcase_35 AC 614 ms
83,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

inf = float("inf")

input = lambda: sys.stdin.readline().rstrip("\r\n")

print = lambda *args, end="\n", sep=" ": sys.stdout.write(
    sep.join(map(str, args)) + end
)


def II():
    return int(input())


def MII(b=0):
    return map(lambda x: int(x) - b, input().split())


def LII(b=0):
    return list(MII(b))


def find_maximum(check, l, r=None, precision=10**-9):

    if r is None:
        r = 1
        while check(r):
            l = r
            r *= 10

    res = l
    while r - l >= precision:
        mid = [(l + r) / 2, (l + r) // 2][precision == 0]
        if check(mid):
            res = mid
            l = mid + (precision == 0)
        else:
            r = mid - (precision == 0)
    return res


def find_minimun(check, l, r=None, precision=10**-9):
    def chk(x):
        return not check(x)

    res = find_maximum(chk, l, r, precision)
    return res + 1 if precision == 0 else res


def is_sorted(a):
    return all(a[i] < a[i + 1] for i in range(len(a) - 1))


for _ in range(II()):
    n, a = II(), LII()

    def check(m):
        b = [ai + i * m for i, ai in enumerate(a, 1)]
        return is_sorted(b)

    print(find_minimun(check, -1, precision=0))
0