結果
問題 |
No.1816 MUL-DIV Game
|
ユーザー |
![]() |
提出日時 | 2023-05-24 01:57:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 99 ms / 2,000 ms |
コード長 | 992 bytes |
コンパイル時間 | 1,049 ms |
コンパイル使用メモリ | 109,288 KB |
最終ジャッジ日時 | 2025-02-13 04:21:47 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream> #include <vector> #include <cmath> #include <map> #include <set> #include <iomanip> #include <queue> #include <algorithm> #include <numeric> #include <deque> #include <complex> #include <cassert> using namespace std; using ll = long long; int main(){ ll N, A, a, b; cin >> N; multiset<ll> st; for (int i=0; i<N; i++){ cin >> A; st.insert(A); } if (N == 1){ cout << *st.begin() << endl; return 0; } if (N == 2){ cout << (*st.begin()) * (*st.rbegin()) << endl; return 0; } if (N % 2 == 1){ cout << 1 << endl; return 0; } while(st.size() > 2){ a = *st.begin(); st.erase(st.begin()); b = *st.begin(); st.erase(st.begin()); st.insert(a*b); st.erase(st.find(*st.rbegin())); st.erase(st.find(*st.rbegin())); st.insert(1); } cout << (*st.begin()) * (*st.rbegin()) << endl; return 0; }