結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー betrue12betrue12
提出日時 2020-08-09 19:44:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 2,283 ms
コンパイル使用メモリ 195,780 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2024-04-15 13:48:29
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 2 ms
5,376 KB
testcase_22 AC 40 ms
5,888 KB
testcase_23 AC 40 ms
5,888 KB
testcase_24 AC 37 ms
5,888 KB
testcase_25 AC 40 ms
5,888 KB
testcase_26 AC 43 ms
6,144 KB
testcase_27 AC 44 ms
6,144 KB
testcase_28 AC 47 ms
6,400 KB
testcase_29 AC 38 ms
5,760 KB
testcase_30 AC 41 ms
6,016 KB
testcase_31 AC 40 ms
5,888 KB
testcase_32 AC 40 ms
5,888 KB
testcase_33 AC 43 ms
6,144 KB
testcase_34 AC 43 ms
6,144 KB
testcase_35 AC 44 ms
6,272 KB
testcase_36 AC 46 ms
6,272 KB
testcase_37 AC 48 ms
6,272 KB
testcase_38 AC 39 ms
5,760 KB
testcase_39 AC 38 ms
6,016 KB
testcase_40 AC 42 ms
6,016 KB
testcase_41 AC 44 ms
6,400 KB
testcase_42 AC 34 ms
6,400 KB
testcase_43 AC 35 ms
6,528 KB
testcase_44 AC 50 ms
6,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N, S, T;
    cin >> N >> S >> T;
    S--; T--;
    vector<int64_t> A(2*N), sum(2*N+1);
    for(int i=0; i<N; i++){
        cin >> A[i];
        A[i+N] = A[i];
    }
    for(int i=0; i<2*N; i++) sum[i+1] = sum[i] + A[i];
    int num = (N+1)/2;

    if(S < T) S += N;
    int M1 = (S+T+1)/2;
    S %= N;
    if(T < S) T += N;
    int M2 = (S+T)/2 - num + 1;
    if(M2 < M1) M2 += N;

    int64_t mx = 0;
    for(int s=M1; s<=M2; s++){
        int s1 = s%N;
        mx = max(mx, sum[s1+num]-sum[s1]);
    }

    cout << mx-(sum[N]-mx) << endl;
    return 0;
}
0