結果

問題 No.1816 MUL-DIV Game
ユーザー se1ka2se1ka2
提出日時 2022-01-21 21:39:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 485 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 72,668 KB
実行使用メモリ 6,292 KB
最終ジャッジ日時 2023-08-17 05:16:56
合計ジャッジ時間 6,684 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 RE -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 9 ms
4,380 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 AC 55 ms
6,292 KB
testcase_14 AC 27 ms
4,920 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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