結果
| 問題 | 
                            No.258 回転寿司(2)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             rlangevin
                         | 
                    
| 提出日時 | 2023-09-28 12:36:43 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 49 ms / 2,000 ms | 
| コード長 | 395 bytes | 
| コンパイル時間 | 206 ms | 
| コンパイル使用メモリ | 82,176 KB | 
| 実行使用メモリ | 53,248 KB | 
| 最終ジャッジ日時 | 2024-07-21 07:14:51 | 
| 合計ジャッジ時間 | 6,647 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 67 | 
ソースコード
N = int(input())
V = list(map(int, input().split()))
inf = 10 ** 18
dp0 = [-inf] * (N + 1)
dp1 = [-inf] * (N + 1)
dp0[0] = 0
for i in range(N):
    dp1[i + 1] = dp0[i] + V[i]
    dp0[i + 1] = max(dp0[i], dp1[i])
now = max(dp1)
print(now)
ans = []
for i in range(N, 0, -1):
    if now == dp1[i] and now == dp0[i - 1] + V[i - 1]:
        ans.append(i)
        now -= V[i - 1]
print(*sorted(ans))
            
            
            
        
            
rlangevin