結果
| 問題 |
No.258 回転寿司(2)
|
| コンテスト | |
| ユーザー |
Lepton_s
|
| 提出日時 | 2015-07-31 22:40:22 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,032 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 86,408 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-24 08:57:41 |
| 合計ジャッジ時間 | 3,986 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 2 |
| other | WA * 67 |
ソースコード
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;
#define N 2000
int dp[N][2];
int main(){
int n;
cin>>n;
vector<int> d(n);
for(int i = 0; i < n; i++) cin>>d[i];
for(int i = 0; i < n; i++){
dp[i+1][0] = max(dp[i][0], dp[i][1]);
dp[i+1][1] = max(dp[i][0]+d[i], dp[i][1]);
}
int res = max(dp[n][0], dp[n][1]), res2 = res;
vector<int> r;
for(int i = n; i > 0; i--){
if(res==dp[i][1]){
r.push_back(i);
res -= d[i-1];
}
}
reverse(r.begin(), r.end());
cout<<res2<<endl;
for(auto x: r) cout<<x<<" ";
cout<<endl;
return 0;
}
Lepton_s