結果

問題 No.45 回転寿司
ユーザー nonnon
提出日時 2019-03-06 21:55:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 776 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 167,464 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-27 16:49:18
合計ジャッジ時間 2,585 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,380 KB
testcase_27 AC 2 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,384 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

int main()
{
  int num;
  cin >> num;

  vector<int> v(num + 10, 0);
  for (int i = 0; i < num; ++i)
  {
    int tmp;
    cin >> tmp;
    v[i] = tmp;
  }

  long long result_o = 0;
  long long result_x = 0;

  for (int i = 0; i < num; i += 3)
  {
    vector<int> vo(3, 0);
    vector<int> vx(3, 0);

    // oxo, xxo, xxo
    vo[0] = result_x + v[i] + v[i + 2];
    vo[1] = result_o + v[i + 2];
    vo[2] = result_x + v[i + 2];
    // xox, xox, oxx
    vx[0] = result_o + v[i + 1];
    vx[1] = result_x + v[i + 1];
    vx[2] = result_x + v[i];

    result_o = *std::max_element(vo.begin(), vo.end());
    result_x = *std::max_element(vx.begin(), vx.end());
  }

  cout << ((result_o > result_x) ? result_o : result_x) << endl;
}
0