結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー weakenweaken
提出日時 2021-05-22 11:39:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 2,350 ms
コンパイル使用メモリ 200,056 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-18 17:34:24
合計ジャッジ時間 3,582 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 11 ms
5,376 KB
testcase_08 AC 11 ms
5,376 KB
testcase_09 AC 11 ms
5,376 KB
testcase_10 WA -
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 3 ms
5,376 KB
testcase_15 AC 2 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 WA -
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 3 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

void solve() {
  int n, m, x, y;
  cin >> n >> m >> x >> y;

  vector<int> must, other;
  rep(_, n) {
    int tbeet;
    cin >> tbeet;
    if (tbeet >= x) {
      must.emplace_back(tbeet);
    } else if (tbeet <= y) {
      // ignore
    } else {
      other.emplace_back(tbeet);
    }
  }

  if ((int)must.size() >= m) {
    cout << "Handicapped" << '\n';
    return;
  }

  sort(other.begin(), other.end());
  reverse(other.begin(), other.end());

  int ans = 0;
  for (const auto m : must) ans += m;
  rep(i, min(m - must.size(), other.size())) { ans += other[i]; }

  cout << ans << '\n';
}

int main() {
  FastIO;
  solve();
  return 0;
}
0