結果

問題 No.1150 シュークリームゲーム(Easy)
ユーザー trineutrontrineutron
提出日時 2020-08-08 07:56:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 2,238 ms
コンパイル使用メモリ 209,324 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-08 11:16:28
合計ジャッジ時間 6,146 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 37 ms
6,676 KB
testcase_23 AC 38 ms
6,676 KB
testcase_24 AC 34 ms
6,676 KB
testcase_25 AC 36 ms
6,676 KB
testcase_26 AC 40 ms
6,676 KB
testcase_27 AC 42 ms
6,676 KB
testcase_28 AC 44 ms
6,676 KB
testcase_29 AC 35 ms
6,676 KB
testcase_30 AC 39 ms
6,676 KB
testcase_31 AC 37 ms
6,676 KB
testcase_32 AC 37 ms
6,676 KB
testcase_33 AC 39 ms
6,676 KB
testcase_34 AC 40 ms
6,676 KB
testcase_35 AC 41 ms
6,676 KB
testcase_36 AC 43 ms
6,676 KB
testcase_37 AC 42 ms
6,676 KB
testcase_38 AC 36 ms
6,676 KB
testcase_39 AC 36 ms
6,676 KB
testcase_40 AC 38 ms
6,676 KB
testcase_41 AC 41 ms
6,676 KB
testcase_42 AC 32 ms
6,676 KB
testcase_43 AC 32 ms
6,676 KB
testcase_44 AC 46 ms
6,676 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(n);
    for (int i = 0; i < n; i++) {
        cin >> a.at(i);
    }
    
    auto distance = [n](int k, int l) {
        return min(abs(k - l), n - abs(k - l));
    };
    
    int64_t s_315 = 0, s_8128 = 0;
    vector<int64_t> neutral;
    for (int i = 0; i < n; i++) {
        int d_315 = distance(i, s), d_8128 = distance(i, t);
        if (d_315 < d_8128) {
            s_315 += a.at(i);
        } else if (d_315 > d_8128) {
            s_8128 += a.at(i);
        } else {
            neutral.push_back(a.at(i));
        }
    }
    sort(neutral.rbegin(), neutral.rend());
    
    for (int i = 0; i < neutral.size(); i++) {
        if (i == 0) {
            s_315 += neutral.at(i);
        } else {
            s_8128 += neutral.at(i);
        }
    }
    
    cout << s_315 - s_8128 << endl;
}
0