結果
問題 |
No.3130 Twin's Add Max Min Game
|
ユーザー |
![]() |
提出日時 | 2025-04-25 23:21:13 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 897 bytes |
コンパイル時間 | 4,514 ms |
コンパイル使用メモリ | 291,560 KB |
実行使用メモリ | 18,912 KB |
最終ジャッジ日時 | 2025-04-25 23:21:29 |
合計ジャッジ時間 | 15,133 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 45 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; void op(ll &x, ll y, string s) { if(s == "add") x = x + y; if(s == "max") x = max(x, y); if(s == "min") x = min(x, y); } ll eval(vector<ll> A, vector<string> B) { ll x = 0; const int N = A.size(); for(int i = 0; i < N; i++) op(x, A[i], B[i]); return x; } int main() { int N; cin >> N; vector<ll> A(N); vector<string> B(N); for(int i = 0; i < N; i++) { cin >> A[i]; } for(int i = 0; i < N; i++) { cin >> B[i]; } sort(A.begin(), A.end()); sort(B.begin(), B.end()); if(B[0] == "min") { cout << 0 << endl; return 0; } int p = N; while(p > 0 && B[p - 1] == "min") p--; swap(A[0], A[p - 1]); reverse(B.begin() + 1, B.begin() + p); // for(int x : A) cout << x << " " ; cout << "\n"; // for(auto s : B) cout << s << " " ; cout <<"\n"; cout << eval(A, B) << endl; }