結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー rokahikou1rokahikou1
提出日時 2020-08-08 02:21:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 1,424 bytes
コンパイル時間 1,247 ms
コンパイル使用メモリ 98,260 KB
実行使用メモリ 5,412 KB
最終ジャッジ日時 2023-10-25 09:43:48
合計ジャッジ時間 3,545 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 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
5,132 KB
testcase_23 AC 38 ms
5,052 KB
testcase_24 AC 36 ms
5,000 KB
testcase_25 AC 38 ms
5,032 KB
testcase_26 AC 41 ms
5,288 KB
testcase_27 AC 42 ms
5,380 KB
testcase_28 AC 44 ms
5,148 KB
testcase_29 AC 36 ms
4,876 KB
testcase_30 AC 40 ms
5,076 KB
testcase_31 AC 39 ms
5,316 KB
testcase_32 AC 38 ms
5,056 KB
testcase_33 AC 40 ms
5,076 KB
testcase_34 AC 41 ms
5,108 KB
testcase_35 AC 42 ms
5,236 KB
testcase_36 AC 43 ms
5,224 KB
testcase_37 AC 43 ms
5,412 KB
testcase_38 AC 38 ms
5,024 KB
testcase_39 AC 37 ms
5,140 KB
testcase_40 AC 39 ms
5,072 KB
testcase_41 AC 43 ms
5,124 KB
testcase_42 AC 33 ms
5,156 KB
testcase_43 AC 34 ms
5,156 KB
testcase_44 AC 47 ms
5,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    int s, t;
    cin >> s >> t;
    s--, t--;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll sum = 0;
    rep(i, N) sum += A[i];
    vector<ll> B, C;
    for(int i = s + 1; i != t; i = (i + 1) % N) {
        B.pb(A[i]);
    }
    for(int i = (s - 1 + N) % N; i != t; i = (i - 1 + N) % N) {
        C.pb(A[i]);
    }
    int bs = B.size(), cs = C.size();
    ll X = A[s], Y = A[t];
    for(int i = 0; i < bs / 2; i++)
        X += B[i];
    for(int i = 0; i < cs / 2; i++)
        X += C[i];
    if(bs % 2 == 0 && cs % 2 == 0) {

    } else if(bs % 2 == 1 && cs % 2 == 0) {
        X += B[bs / 2];
    } else if(bs % 2 == 0 && cs % 2 == 1) {
        X += C[cs / 2];
    } else {
        X += max(B[bs / 2], C[cs / 2]);
    }
    Y = sum - X;
    cout << X - Y << endl;
    return 0;
}
0