結果
| 問題 | No.258 回転寿司(2) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-03-15 01:12:12 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,201 bytes |
| 記録 | |
| コンパイル時間 | 1,176 ms |
| コンパイル使用メモリ | 217,640 KB |
| 実行使用メモリ | 7,720 KB |
| 最終ジャッジ日時 | 2026-03-15 01:12:32 |
| 合計ジャッジ時間 | 19,740 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 WA * 3 |
| other | WA * 67 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
long long C=0;
cin >> n;
vector<long long> a(n+1), dp(n+1,LLONG_MIN);
vector<int> pre(n+1,-1);
for(int i=1;i<=n;i++) cin >> a[i];
long long best_val = LLONG_MIN;
int best_pos = -1;
long long ans = LLONG_MIN;
int pos = -1;
for(int i=1;i<=n;i++){
dp[i] = a[i];
pre[i] = -1;
if(best_val != LLONG_MIN){
long long cand = a[i] - C*i + best_val;
if(cand > dp[i]){
dp[i] = cand;
pre[i] = best_pos;
}
}
if(dp[i] > ans){
ans = dp[i];
pos = i;
}
if(i >= 3){
long long val = dp[i-2] + C*(i-2);
if(val > best_val){
best_val = val;
best_pos = i-2;
}
}
}
vector<int> path;
while(pos != -1){
path.push_back(pos);
pos = pre[pos];
}
reverse(path.begin(), path.end());
cout << ans << "\n";
cout << path.size() << "\n";
for(int x: path) cout << x << " ";
return 0;
}