結果
| 問題 |
No.3130 Twin's Add Max Min Game
|
| コンテスト | |
| ユーザー |
pockyny
|
| 提出日時 | 2025-07-10 02:09:59 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 132 ms / 2,000 ms |
| コード長 | 638 bytes |
| コンパイル時間 | 1,011 ms |
| コンパイル使用メモリ | 79,380 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2025-07-10 02:10:09 |
| 合計ジャッジ時間 | 9,447 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 56 |
ソースコード
#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) x = min(x,a[mx + ad]);
cout << x << "\n";
}
}
pockyny