結果

問題 No.45 回転寿司
ユーザー kuisiba
提出日時 2016-10-14 14:19:30
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 948 ms
コンパイル使用メモリ 61,580 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-27 15:24:40
合計ジャッジ時間 1,527 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdint>
#include <vector>
#include <algorithm>

using namespace std;

int main() {

  ios::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> v(n + 1, 0);
  for (int i = 1; i < n + 1; i++) {
    cin >> v.at(i);
  }
  for (int i = 2; i < n + 1; i++) {
    v.at(i) = max(v.at(i - 1), v.at(i) + v.at(i - 2));
  }

  cout << v.at(n) << endl;
  return 0;
}
0