結果

問題 No.1816 MUL-DIV Game
ユーザー KichicoKichico
提出日時 2022-01-21 21:47:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 2,448 bytes
コンパイル時間 1,727 ms
コンパイル使用メモリ 174,172 KB
実行使用メモリ 8,284 KB
最終ジャッジ日時 2023-08-17 05:33:57
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 24 ms
5,468 KB
testcase_11 AC 21 ms
5,212 KB
testcase_12 AC 15 ms
4,788 KB
testcase_13 AC 35 ms
6,180 KB
testcase_14 AC 18 ms
4,972 KB
testcase_15 AC 24 ms
5,564 KB
testcase_16 AC 6 ms
4,376 KB
testcase_17 AC 51 ms
7,232 KB
testcase_18 AC 49 ms
6,952 KB
testcase_19 AC 21 ms
5,284 KB
testcase_20 AC 52 ms
7,428 KB
testcase_21 AC 16 ms
4,888 KB
testcase_22 AC 12 ms
4,528 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 64 ms
8,008 KB
testcase_26 AC 66 ms
8,032 KB
testcase_27 AC 66 ms
8,080 KB
testcase_28 AC 68 ms
8,284 KB
testcase_29 AC 65 ms
8,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
using ll = int64_t;
using ld = long double;
using ull = unsigned long long;
#define ALL(x) x.begin(),x.end()
#define rep(iter,from,to) for(ll iter=from;iter<to;++iter)
#define fore(variable,container) for(auto& variable:container)
#define forc(variable,container) for(auto& variable:container) cout<<variable<<endl;
const ll MOD = 1e9 + 7;
const ll INF = 1e17;
const vector<ll> dx{ 1,0,-1,0 }, dy{ 0,1,0,-1 };
//#######################################################################
void op(vector<ll> vec) {
    ll size = (ll)vec.size();
    for (ll i = 0; i < size - 1; ++i) cout << vec[i] << " ";
    cout << vec.back() << endl;
}

void op(vector<vector<ll>> vec) {
    ll height = (ll)vec.size();
    ll width = (ll)vec[0].size();
    for (ll i = 0; i < height; ++i) {
        for (ll j = 0; j < width - 1; ++j) cout << vec[i][j] << " ";
        cout << vec[i].back() << endl;
    }
}

void twoText(bool identifier, string outTrue, string outFalse) {
    if (identifier) cout << outTrue << endl;
    else cout << outFalse << endl;
}

void twoText(bool identifier) {
    if (identifier) cout << "Yes" << endl;
    else cout << "No" << endl;
}

template <class T>
T vecsum(vector<T>& vec) {
    return accumulate(ALL(vec), (T)0);
}

template<class T, ll>
T vecsum(vector<T>& vec, ll K) {
    ll ret = 0;
    rep(i, 0, K) ret += vec[i];
    return ret;
}

template <class T>
struct grid {
    vector<vector<T>> field;
    grid(ll height, ll width) { field = vector<vector<T>>(height, vector<T>(width, (T)0)); }
    void input() { rep(i, 0, field.size()) rep(j, 0, field[i].size()) cin >> field[i][j]; }
};

//#########################################################################

void solve() {
    ll N; cin >> N;
    multiset<ll> st;
    rep(i, 0, N) {
        ll v; cin >> v; st.emplace(v);
    }
    while (st.size() > 1) {
        auto lv = *st.begin();
        st.erase(st.find(lv));
        auto lv2 = *st.begin();
        st.erase(st.find(lv2));
        st.emplace(lv * lv2);
        if (st.size() == 1) break;
        auto mv = *st.rbegin();
        st.erase(st.find(mv));
        auto mv2 = *st.rbegin();
        st.erase(st.find(mv2));
        st.emplace((ll)(ceil((ld)mv2 / (ld)mv)));
    }
    cout << *st.begin() << endl;
}


int main(void) {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}
0