結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー MisterMister
提出日時 2021-03-31 21:26:36
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 812 bytes
コンパイル時間 706 ms
コンパイル使用メモリ 81,100 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-21 23:20:41
合計ジャッジ時間 1,658 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 11 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 10 ms
4,376 KB
testcase_08 AC 10 ms
4,376 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "main.cpp"
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;
using lint = long long;

void solve() {
    int n, m, r, l;
    cin >> n >> m >> r >> l;

    vector<lint> xs;
    lint sum = 0;
    while (n--) {
        lint x;
        cin >> x;

        if (x <= l) {
            continue;
        } else if (x >= r) {
            sum += x;
            --m;
        } else {
            xs.push_back(x);
        }
    }

    if (m < 0) {
        cout << "Handicapped\n";
        return;
    }

    sort(xs.begin(), xs.end());
    while (m > 0 && !xs.empty()) {
        sum += xs.back();
        xs.pop_back();
        --m;
    }

    cout << sum << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    solve();

    return 0;
}
0