結果

問題 No.1816 MUL-DIV Game
ユーザー CyanmondCyanmond
提出日時 2022-01-21 21:35:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 2,077 bytes
コンパイル時間 2,395 ms
コンパイル使用メモリ 205,020 KB
実行使用メモリ 8,836 KB
最終ジャッジ日時 2023-08-17 05:10:05
合計ジャッジ時間 4,490 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 8 ms
4,376 KB
testcase_10 AC 33 ms
5,456 KB
testcase_11 AC 30 ms
5,172 KB
testcase_12 AC 22 ms
4,732 KB
testcase_13 AC 47 ms
6,512 KB
testcase_14 AC 25 ms
4,908 KB
testcase_15 AC 33 ms
5,592 KB
testcase_16 AC 8 ms
4,380 KB
testcase_17 AC 66 ms
7,464 KB
testcase_18 AC 62 ms
7,180 KB
testcase_19 AC 30 ms
5,236 KB
testcase_20 AC 69 ms
7,720 KB
testcase_21 AC 22 ms
4,776 KB
testcase_22 AC 17 ms
4,488 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 85 ms
8,628 KB
testcase_26 AC 86 ms
8,564 KB
testcase_27 AC 87 ms
8,636 KB
testcase_28 AC 84 ms
8,508 KB
testcase_29 AC 83 ms
8,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "paper.cpp"
#include <bits/stdc++.h>

#line 2 "library2/utility/ceil_div.hpp"

template <typename T> constexpr T ceil_div(const T a, const T b) {
    return (a + b - 1) / b;
}
#line 3 "library2/utility/int_alias.hpp"

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
#line 3 "library2/utility/rep.hpp"

class Range {
    struct Iterator {
        int itr;
        constexpr Iterator(const int pos) noexcept : itr(pos) {}
        constexpr void operator++() noexcept {
            ++itr;
        }
        constexpr bool operator!=(const Iterator &other) const noexcept {
            return itr != other.itr;
        }
        constexpr int operator*() const noexcept {
            return itr;
        }
    };
    const Iterator first, last;

  public:
    explicit constexpr Range(const int f, const int l) noexcept
        : first(f), last(std::max(f, l)) {}
    constexpr Iterator begin() const noexcept {
        return first;
    }
    constexpr Iterator end() const noexcept {
        return last;
    }
};

constexpr Range rep(const int l, const int r) noexcept {
    return Range(l, r);
}
constexpr Range rep(const int n) noexcept {
    return Range(0, n);
}
#line 3 "library2/utility/scan.hpp"

template <typename T = int> T scan() {
    T ret;
    std::cin >> ret;
    return ret;
}
#line 7 "paper.cpp"

int main() {
    const int N = scan();
    std::vector<i64> A(N);
    for (auto &e : A) {
        e = scan();
    }

    std::multiset<i64> S;
    for (const auto e : A) {
        S.insert(e);
    }

    // エスパー...
    for (const int i : rep(N - 1)) {
        if (i & 1) {
            S.insert(ceil_div(*++S.rbegin(), *S.rbegin()));
            S.erase(--S.end());
            S.erase(--S.end());
        } else {
            S.insert(*S.begin() * *++S.begin());
            S.erase(S.begin());
            S.erase(S.begin());
        }
    }

    std::cout << *S.begin() << std::endl;
}
0