結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー tonyu0tonyu0
提出日時 2020-08-09 20:37:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,098 bytes
コンパイル時間 1,087 ms
コンパイル使用メモリ 99,772 KB
実行使用メモリ 5,344 KB
最終ジャッジ日時 2023-07-28 05:38:46
合計ジャッジ時間 4,911 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 WA -
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 35 ms
4,836 KB
testcase_23 AC 35 ms
4,764 KB
testcase_24 RE -
testcase_25 AC 34 ms
4,788 KB
testcase_26 AC 38 ms
4,940 KB
testcase_27 AC 41 ms
5,344 KB
testcase_28 RE -
testcase_29 AC 33 ms
4,588 KB
testcase_30 AC 37 ms
4,924 KB
testcase_31 AC 35 ms
5,140 KB
testcase_32 WA -
testcase_33 RE -
testcase_34 AC 39 ms
4,908 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 40 ms
5,232 KB
testcase_38 AC 34 ms
4,744 KB
testcase_39 WA -
testcase_40 AC 36 ms
4,820 KB
testcase_41 RE -
testcase_42 AC 30 ms
4,852 KB
testcase_43 WA -
testcase_44 AC 44 ms
4,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

int main() {
  int n, s, t;
  cin >> n >> s >> t;
  --s, --t;
  vector<ll> a(n);
  for (ll& x : a) cin >> x;

  vector<ll> x, y;
  for (int i = (s + 1) % n; i != t; i = (i + 1) % n) x.push_back(a[i]);
  for (int i = (t + 1) % n; i != s; i = (i + 1) % n) y.push_back(a[i]);
  reverse(y.begin(), y.end());

  int xs = (int)x.size();
  int ys = (int)y.size();
  ll vs = a[s], vt = a[t];

  if (xs % 2 == 0) {
    rep(i, 0, xs / 2) vs += x[i];
    rep(i, xs / 2, xs) vt += x[i];
  } else {
    rep(i, 0, xs / 2 + 1) vs += x[i];
    rep(i, xs / 2 + 1, xs) vt += x[i];
  }
  if (ys % 2 == 0) {
    rep(i, 0, ys / 2) vs += y[i];
    rep(i, ys / 2, ys) vt += y[i];
  } else {
    rep(i, 0, ys / 2 + 1) vs += y[i];
    rep(i, ys / 2 + 1, xs) vt += y[i];
  }

  if (xs & 1 && ys & 1) {
    ll mn = min(x[xs / 2], y[ys / 2]);
    vs -= mn;
    vt += mn;
  }

  cout << vs - vt << endl;
  return 0;
}
0