結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー SSRSSSRS
提出日時 2020-08-07 21:50:49
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 762 bytes
コンパイル時間 1,692 ms
コンパイル使用メモリ 170,856 KB
実行使用メモリ 6,936 KB
最終ジャッジ日時 2023-10-25 00:47:07
合計ジャッジ時間 4,119 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 38 ms
6,212 KB
testcase_23 AC 39 ms
6,476 KB
testcase_24 AC 36 ms
6,212 KB
testcase_25 AC 38 ms
6,212 KB
testcase_26 AC 42 ms
6,476 KB
testcase_27 AC 43 ms
6,740 KB
testcase_28 AC 44 ms
6,676 KB
testcase_29 AC 37 ms
6,212 KB
testcase_30 AC 41 ms
6,476 KB
testcase_31 AC 39 ms
6,476 KB
testcase_32 AC 38 ms
6,212 KB
testcase_33 AC 40 ms
6,476 KB
testcase_34 AC 42 ms
6,740 KB
testcase_35 AC 42 ms
6,740 KB
testcase_36 AC 43 ms
6,672 KB
testcase_37 AC 44 ms
6,676 KB
testcase_38 AC 38 ms
6,212 KB
testcase_39 AC 37 ms
6,212 KB
testcase_40 AC 40 ms
6,476 KB
testcase_41 AC 43 ms
6,740 KB
testcase_42 AC 33 ms
6,936 KB
testcase_43 AC 33 ms
6,936 KB
testcase_44 AC 47 ms
6,936 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000000000;
int main(){
  int N;
  cin >> N;
  int s, t;
  cin >> s >> t;
  s--;
  t--;
  s += N;
  if (t + N < s){
    t += N;
  }
  vector<int> A(N * 3);
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[N + i] = A[i];
    A[N * 2 + i] = A[i];
  }
  vector<long long> S(N * 3 + 1);
  S[0] = 0;
  for (int i = 0; i < N * 3; i++){
    S[i + 1] = S[i] + A[i];
  }
  long long ans = -INF;
  for (int i = 0; i < N * 2; i++){
    int j = i + (N + 1) / 2;
    if (t <= i && i <= s && j >= s){
      if (s - i <= i - t && j - s - 1 <= (t + N) - j + 1){
        long long X = S[j] - S[i];
        long long Y = S[N] - X;
        ans = max(ans, X - Y);
      }
    }
  }
  cout << ans << endl;
}
0