結果

問題 No.72 そろばん Med
ユーザー Coki628Coki628
提出日時 2020-12-04 02:11:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 74 ms / 5,000 ms
コード長 1,275 bytes
コンパイル時間 492 ms
コンパイル使用メモリ 87,448 KB
実行使用メモリ 71,860 KB
最終ジャッジ日時 2023-10-12 13:57:21
合計ジャッジ時間 4,661 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,680 KB
testcase_01 AC 71 ms
71,540 KB
testcase_02 AC 73 ms
71,788 KB
testcase_03 AC 70 ms
71,696 KB
testcase_04 AC 72 ms
71,776 KB
testcase_05 AC 72 ms
71,544 KB
testcase_06 AC 70 ms
71,804 KB
testcase_07 AC 71 ms
71,640 KB
testcase_08 AC 69 ms
71,804 KB
testcase_09 AC 72 ms
71,660 KB
testcase_10 AC 70 ms
71,344 KB
testcase_11 AC 74 ms
71,644 KB
testcase_12 AC 73 ms
71,776 KB
testcase_13 AC 72 ms
71,776 KB
testcase_14 AC 71 ms
71,860 KB
testcase_15 AC 71 ms
71,516 KB
testcase_16 AC 71 ms
71,684 KB
testcase_17 AC 72 ms
71,624 KB
testcase_18 AC 71 ms
71,536 KB
testcase_19 AC 73 ms
71,744 KB
testcase_20 AC 73 ms
71,704 KB
testcase_21 AC 72 ms
71,680 KB
testcase_22 AC 72 ms
71,812 KB
testcase_23 AC 72 ms
71,640 KB
testcase_24 AC 70 ms
71,796 KB
testcase_25 AC 72 ms
71,612 KB
testcase_26 AC 71 ms
71,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 19
MOD = 10 ** 6 + 7
EPS = 10 ** -10

def trisearch_max(lo, hi, func, ln=0):
    """ 三分探索 """

    m1 = l = lo
    m2 = r = hi
    while lo+2 < hi:
        m1 = (lo*2+hi) // 3
        m2 = (lo+hi*2) // 3
        res1 = func(m1)
        res2 = func(m2)
        if res1 >= res2:
            hi = m2
        else:
            lo = m1
    mx = -INF
    ret = ()
    for i in range(max(m1-ln, l+1), min(m2+ln, r+1)):
        res = func(i)
        if res > mx:
            mx = res
            ret = (i, res)
    return ret

def calc(i):
    j = N - i
    return (i+1)*(j+1)-1

N = INT()
res = trisearch_max(-1, N, calc, 10)
print(res[1]%MOD)
0