結果

問題 No.3130 Twin's Add Max Min Game
コンテスト
ユーザー pockyny
提出日時 2025-07-10 02:07:15
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 500 ms
コンパイル使用メモリ 98,216 KB
実行使用メモリ 9,276 KB
最終ジャッジ日時 2026-07-13 02:25:06
合計ジャッジ時間 7,244 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28 WA * 28
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:25:21: warning: ignoring return value of 'constexpr const _Tp& std::min(const _Tp&, const _Tp&) [with _Tp = long long int]', declared with attribute 'nodiscard' [-Wunused-result]
   25 |         if(mn>0) min(x,a[mx + ad]);
      |                  ~~~^~~~~~~~~~~~~~
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/string:53,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/locale_classes.h:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/ios_base.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ios:46,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/ostream.h:43,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/ostream:42,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/iostream:43,
                 from main.cpp:1:
/home/linuxbrew/.linuxbrew/Cellar/gcc@15/15.3.0/include/c++/15/bits/stl_algobase.h:234:5: note: declared here
  234 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~

ソースコード

diff #
raw source code

#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