結果

問題 No.72 そろばん Med
ユーザー バカらっくバカらっく
提出日時 2019-09-25 08:16:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 27 ms / 5,000 ms
コード長 875 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 11,980 KB
実行使用メモリ 10,164 KB
最終ジャッジ日時 2023-10-21 14:53:03
合計ジャッジ時間 1,889 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
10,164 KB
testcase_01 AC 23 ms
10,152 KB
testcase_02 AC 23 ms
10,152 KB
testcase_03 AC 27 ms
10,152 KB
testcase_04 AC 24 ms
10,160 KB
testcase_05 AC 23 ms
10,160 KB
testcase_06 AC 24 ms
10,164 KB
testcase_07 AC 23 ms
10,160 KB
testcase_08 AC 23 ms
10,164 KB
testcase_09 AC 23 ms
10,160 KB
testcase_10 AC 23 ms
10,160 KB
testcase_11 AC 24 ms
10,164 KB
testcase_12 AC 23 ms
10,160 KB
testcase_13 AC 23 ms
10,164 KB
testcase_14 AC 22 ms
10,164 KB
testcase_15 AC 23 ms
10,164 KB
testcase_16 AC 23 ms
10,164 KB
testcase_17 AC 23 ms
10,160 KB
testcase_18 AC 23 ms
10,160 KB
testcase_19 AC 23 ms
10,164 KB
testcase_20 AC 24 ms
10,160 KB
testcase_21 AC 23 ms
10,164 KB
testcase_22 AC 23 ms
10,160 KB
testcase_23 AC 23 ms
10,164 KB
testcase_24 AC 23 ms
10,160 KB
testcase_25 AC 23 ms
10,164 KB
testcase_26 AC 23 ms
10,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

n = int(input())


def getMax(bigBallCount):
    if bigBallCount == 0:
        return n
    baseNum = n - bigBallCount + 1
    return bigBallCount * baseNum + (baseNum - 1)


def getAns(minCount, maxCount):
    idx1 = minCount + int((maxCount - minCount) / 3)
    idx2 = minCount + int((maxCount - minCount) * 2 / 3)
    if maxCount - minCount <= 2:
        return max(getMax(minCount), getMax(idx1), getMax(idx2), getMax(maxCount))

    val1 = getMax(minCount)
    val2 = getMax(idx1)
    val3 = getMax(idx2)
    val4 = getMax(maxCount)

    maxVal = max(val1, val2, val3, val4)

    if val1 == maxVal:
        return getAns(minCount, idx1)
    if val2 == maxVal:
        return getAns(minCount, idx2)
    if val3 == maxVal:
        return getAns(idx1, maxCount)
    return getAns(idx2, maxCount)


ans = getAns(0, n - 1) % (1000000 + 7)
print(ans)
0