結果
| 問題 |
No.1454 ツブ消ししとるなEasy
|
| コンテスト | |
| ユーザー |
Ichimiya
|
| 提出日時 | 2021-06-02 02:14:43 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 34 ms / 2,000 ms |
| コード長 | 725 bytes |
| コンパイル時間 | 1,866 ms |
| コンパイル使用メモリ | 173,560 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-09 01:01:21 |
| 合計ジャッジ時間 | 2,956 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 16 |
ソースコード
#include <bits/stdc++.h>
#define NIL (-1)
#define ll long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;
const double PI = acos(-1.0);
int main() {
ll N, M, X, Y;
cin >> N >> M >> X >> Y;
vector<ll> A(N), ck(N);
ll cnt = 0, tot = 0;
for (int i = 0; i < N; i++) {
cin >> A[i];
if (A[i] >= X) {
ck[i] = 2;
cnt++;
tot += A[i];
}
if (A[i] <= Y) ck[i] = 1;
}
if (cnt > M) cout << "Handicapped" << endl;
else {
vector<ll> v;
for (int i = 0; i < N; i++) {
if (!ck[i]) v.push_back(A[i]);
}
sort(v.begin(), v.end());
reverse(v.begin(), v.end());
ll s = v.size();
for (int i = 0; i < min(M - cnt,s); i++) tot += v[i];
cout << tot << endl;
}
return 0;
}
Ichimiya