結果

問題 No.3130 Twin's Add Max Min Game
ユーザー ripity
提出日時 2025-04-25 23:19:30
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 766 bytes
コンパイル時間 4,153 ms
コンパイル使用メモリ 292,744 KB
実行使用メモリ 18,968 KB
最終ジャッジ日時 2025-04-25 23:19:52
合計ジャッジ時間 14,451 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other AC * 45 WA * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#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--;
  reverse(B.begin() + 1, B.begin() + p);
  cout << eval(A, B) << endl;
}
0