結果

問題 No.3130 Twin's Add Max Min Game
ユーザー GOTKAKO
提出日時 2025-04-25 22:23:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 2,193 ms
コンパイル使用メモリ 200,532 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-25 22:23:42
合計ジャッジ時間 6,876 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int N; cin >> N;
    vector<int> Akane(N);
    int Add = 0,Max = 0,Min = 0;
    for(auto &a : Akane) cin >> a;
    for(int i=0; i<N; i++){
        string s; cin >> s;
        if(s == "add") Add++;
        else if(s == "max") Max++;
        else Min++;
    }
    sort(Akane.rbegin(),Akane.rend());
    
    if(Min == N){
        cout << 0 << endl; //かわいそう.
        return 0;
    }
    if(Min == 0){
        long long sum = 0;
        for(int i=N-1; i>=N-Add; i--) sum += Akane.at(i);
        sum = max(sum,1LL*Akane.at(0));
        cout << sum << endl; return 0;
    }
    long long answer = Akane.at(Min);
    for(int i=Min+Max+1; i<N; i++) answer += Akane.at(i);
    cout << answer << endl;
}
 
0