結果

問題 No.1816 MUL-DIV Game
ユーザー iw522
提出日時 2022-01-21 21:41:18
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 834 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 170,544 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-11-25 23:08:08
合計ジャッジ時間 3,303 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 6 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)n; i++)
#define reps(i,n) for(ll i=1; i<=(ll)n; i++)
#define repi(i,a,b) for(ll i=(ll)a; i<(ll)b; i++)
#define pb push_back
#define mp make_pair
#define ALL(i) i.begin(),i.end()
ll INF = 1000000000000000;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll a;
    multiset<ll> st;
    rep(i,n) {
        cin >> a;
        st.insert(a);
    }
    ll now=0;
    while(st.size()!=1){
        ll v=*prev(st.end());
        ll w=*prev(prev(st.end()));
        st.erase(st.find(v));
        st.erase(st.find(w));
        if(now%2) {
           if(v!=0) st.insert(w/v);
           else st.insert(0);
        }
        else st.insert(v*w);
        now++;
    }
    cout << *st.begin() << endl;
}
0