結果
| 問題 |
No.3130 Twin's Add Max Min Game
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-04-25 22:50:39 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,476 bytes |
| コンパイル時間 | 5,822 ms |
| コンパイル使用メモリ | 333,836 KB |
| 実行使用メモリ | 7,848 KB |
| 最終ジャッジ日時 | 2025-04-25 22:51:02 |
| 合計ジャッジ時間 | 10,196 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 28 |
ソースコード
#include <atcoder/all>
#include <bits/stdc++.h>
#define rep(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
using namespace atcoder;
using namespace std;
typedef long long ll;
void solve() {
int n;
cin >> n;
vector<ll> a(n);
rep(i, 0, n) cin >> a[i];
int mx = 0, mn = 0, ad = 0;
rep(i, 0, n) {
string s;
cin >> s;
mx += s == "max";
mn += s == "min";
ad += s == "add";
}
sort(a.begin(), a.end());
while (mn) {
a.pop_back();
mn--;
}
n = a.size();
a.insert(a.begin(), a.back());
a.pop_back();
reverse(a.begin(), a.end());
ll ans = 0;
while (ad) {
ans += a.back();
a.pop_back();
ad--;
}
while (mx) {
ans = max(ans, a.back());
a.pop_back();
mx--;
}
cout << ans << endl;
// auto check = [&](ll mid) {
// auto b = a;
// int bi = 0;
// rep(i, 0, n) bi += a[i] >= mid;
// };
// auto binary = [&]() {
// ll ac = 0, wa = 1e18;
// ll mid = ac + (wa - ac) / 2;
// while (wa - ac > 1) {
// if (check(mid))
// ac = mid;
// else
// wa = mid;
// mid = ac + (wa - ac) / 2;
// }
// return ac;
// };
// cout << binary() << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while (t--) {
solve();
}
}
SnowBeenDiding