結果

問題 No.1454 ツブ消ししとるなEasy
ユーザー weaken
提出日時 2021-05-22 11:39:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 814 bytes
コンパイル時間 2,120 ms
コンパイル使用メモリ 198,920 KB
最終ジャッジ日時 2025-01-21 17:11:37
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 WA * 3
権限があれば一括ダウンロードができます

ソースコード

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