結果

問題 No.45 回転寿司
ユーザー sinofseven
提出日時 2020-07-10 16:55:49
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 673 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 17,576 KB
最終ジャッジ日時 2024-10-11 00:43:20
合計ジャッジ時間 12,778 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import combinations


def is_continuous(iter):
    previous = None
    for v in iter:
        if previous is None:
            previous = v
            continue
        if v - previous == 1:
            return True
    return False


times = int(input())
data = [
    int(x)
    for x in input().split(' ')
]

max_length = int(times / 2 + times % 2)


result = -1
for i in range(max_length):
    length = i + 1
    for comb in combinations(range(times), max_length):
        tmp = 0
        if is_continuous(comb):
            continue
        for index in comb:
            tmp += data[index]
        if result < tmp:
            result = tmp
print(result)
0