Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
1.2 kB
30
Indexable
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
using ll = long long;
template<class T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int dx[] = {0, 0, 1, -1, 1, 1, -1, -1};
int dy[] = {1, -1, 0, 0, 1, -1, 1, -1};

void File() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("errors.txt", "w", stderr);
#else

#endif
}

long double E = 1e-9;

int comp(long double x, long double y) {
    if (x + E < y) return -1;
    if (y + E < x) return 1;
    return 0;
}

int main() {
    File();
    int n;
    cin >> n;
    vector<ll> a(n);
    long double lg = 0;
    for (auto &X: a)
        cin >> X, lg += log2(X);
    ll L = 0, R = 1e10 + 10;
    while (L <= R) {
        ll M = (L + R) / 2;
        if (comp(log2(M) * n, lg) != 1)
            L = M + 1;
        else
            R = M - 1;
    }
    cout << L << "\n";
    return 0;
}
Leave a Comment