結果

問題 No.1816 MUL-DIV Game
コンテスト
ユーザー se1ka2
提出日時 2022-01-21 21:39:18
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
RE  
実行時間 -
コード長 485 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 674 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 11,776 KB
最終ジャッジ日時 2026-05-20 12:30:20
合計ジャッジ時間 8,220 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 9 RE * 3 TLE * 1 -- * 14
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	multiset<ll> st;
	for(int i = 0; i < n; i++){
		ll a;
		cin >> a;
		st.insert(a);
	}
	for(int i = 0; i < n - 1; i++){
		if(i % 2 == 0){
			ll a = *st.begin();
			st.erase(st.begin());
			ll b = *st.begin();
			st.erase(st.begin());
			st.insert(a * b);
		}
		else{
			st.erase(*--st.end());
			st.erase(*--st.end());
			st.insert(1);
		}
	}
	cout << *st.begin() << endl;
}
0