結果

問題 No.45 回転寿司
ユーザー DialBird
提出日時 2017-02-09 09:57:04
言語 C++11
(gcc 15.3.0 + boost 1.92.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
TLE  
実行時間 -
コード長 606 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 323 ms
コンパイル使用メモリ 87,704 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-10-07 20:40:53
合計ジャッジ時間 17,176 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other TLE * 1 -- * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;i++)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

const int MAX_N = 100;
const int MAX_V = 100;
int N;
vector<int> v_list;

int solve(int idx, int total){
  if (idx >= N) return total;

  int res_1 = solve(idx + 1, total);
  int res_2 = solve(idx + 2, total + v_list[idx]);
  return MAX(res_1, res_2);
}

int main(){
  cin >> N;

  int val;
  REP(i,0,N){
    cin >> val;
    v_list.push_back(val);
  }

  cout << solve(0, 0) << endl;
}
0