結果
| 問題 |
No.3130 Twin's Add Max Min Game
|
| コンテスト | |
| ユーザー |
SnowBeenDiding
|
| 提出日時 | 2025-04-26 00:57:25 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,285 bytes |
| コンパイル時間 | 6,151 ms |
| コンパイル使用メモリ | 333,256 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-04-26 00:57:37 |
| 合計ジャッジ時間 | 11,315 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 54 WA * 2 |
ソースコード
#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";
}
if (mx == n) {
cout << a.back() << endl;
return;
}
if (mn == n) {
cout << 0 << endl;
return;
}
if (ad == n) {
cout << accumulate(a.begin(), a.end(), 0LL) << endl;
return;
}
sort(a.begin(), a.end());
ll init_max = a[ad + mx];
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--;
}
ans = min(ans, init_max);
cout << ans << endl;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
while (t--) {
solve();
}
}
SnowBeenDiding