結果
| 問題 | 
                            No.45 回転寿司
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2018-05-20 02:19:10 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 684 bytes | 
| コンパイル時間 | 84 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 1,069,668 KB | 
| 最終ジャッジ日時 | 2024-06-28 14:32:34 | 
| 合計ジャッジ時間 | 12,768 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | -- * 4 | 
| other | MLE * 1 -- * 29 | 
ソースコード
n = int(input())
v = list(map(int, input().split()))
routes = [[1]]
flag = True
ans = []
while flag:
    flag = False
    r = []
    for route in routes:
        if route == []:
            continue
        if route[-1] < n:
            r.append(route + [route[-1] + 2])
            r.append(route[:-1] + [route[-1] + 1])
            flag = True
        elif route[-1] == n:
            ans.append(route)
            ans.append(route[:-1])
        else:
            ans.append(route[:-1])
    if flag == True:
        routes = r
else:
    score = []
    for a in ans:
        s = 0
        for i in a:
            s += v[i-1]
        score.append(s)
    print(max(score))