結果

問題 No.3130 Twin's Add Max Min Game
ユーザー pockyny
提出日時 2025-07-10 02:07:15
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 634 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 81,684 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-10 02:07:27
合計ジャッジ時間 12,126 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;
int main(){
    int i,n; cin >> n;
    vector<ll> a(n);
    for(i=0;i<n;i++) cin >> a[i];
    int ad = 0,mx = 0,mn = 0;
    for(i=0;i<n;i++){
        string s; cin >> s;
        if(s=="add") ad++;
        if(s=="max") mx++;
        if(s=="min") mn++;
    }
    sort(a.begin(),a.end());
    if(ad==0){
        if(mx==0) cout << 0 << "\n";
        else cout << a[mx - 1] << "\n";
    }else{
        ll x = a[mx + ad - 1];
        for(i=0;i<ad - 1;i++) x += a[i];
        if(mn>0) min(x,a[mx + ad]);
        cout << x << "\n";
    }
}
0