Rezultati

Up. imeNalogaJezikRezultatČas oddaje
qubit-2017 Pakiranje piva C++ 100/100OK 20. apr '17 @ 19:10

Test Točke Porabljen spomin Porabljen čas Status
#1 3/3 3,133 MiB 0,004 s OK
#2 3/3 3,070 MiB 0,004 s OK
#3 3/3 3,078 MiB 0,004 s OK
#4 3/3 3,078 MiB 0,004 s OK
#5 3/3 3,129 MiB 0,004 s OK
#6 3/3 3,133 MiB 0,004 s OK
#7 3/3 3,133 MiB 0,004 s OK
#8 3/3 3,203 MiB 0,004 s OK
#9 3/3 3,141 MiB 0,004 s OK
#10 3/3 3,203 MiB 0,004 s OK
#11 3/3 3,141 MiB 0,004 s OK
#12 3/3 3,199 MiB 0,004 s OK
#13 3/3 3,145 MiB 0,004 s OK
#14 3/3 3,141 MiB 0,004 s OK
#15 3/3 3,090 MiB 0,004 s OK
#16 3/3 3,145 MiB 0,004 s OK
#17 3/3 3,145 MiB 0,004 s OK
#18 3/3 3,145 MiB 0,004 s OK
#19 3/3 3,215 MiB 0,016 s OK
#20 3/3 3,137 MiB 0,004 s OK
#21 3/3 3,141 MiB 0,010 s OK
#22 3/3 3,145 MiB 0,004 s OK
#23 3/3 3,145 MiB 0,004 s OK
#24 3/3 3,211 MiB 0,004 s OK
#25 4/4 3,211 MiB 0,010 s OK
#26 4/4 3,133 MiB 0,004 s OK
#27 4/4 3,133 MiB 0,004 s OK
#28 4/4 3,145 MiB 0,004 s OK
#29 4/4 3,141 MiB 0,004 s OK
#30 4/4 3,145 MiB 0,004 s OK
#31 4/4 3,145 MiB 0,010 s OK

Ocenjevani program (n4.cpp):
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <queue>

typedef long long ll;

using namespace std;

inline bool check(vector<ll>& a, ll k, ll n) {
    for (int i = 1; i < n; i++) {
        if (!(a[i] / (k - 1) >= a[i] % (k - 1))) return false;
    }
    return true;
}

int main(void) {
    cin.tie(nullptr);
    cin.sync_with_stdio(false);

    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    unique(a.begin(), a.end());
    N = a.size();
    if (a[0] == 1) {
        cout << 2 << endl;
        return 0;
    }
    for (ll i = 1; i <= (a[0] + 1); i++) {
        ll k = (a[0] + (i - a[0] % i)) / i;
        // if (k <= 2) {
        //     cout << 2 << endl;
        //     break;
        // }
        if (check(a, k, N)) {
            cout << k << endl;
            break;
        }
        if (a[0] % i == 0) {
            //cout << k << endl;
            if (check(a, k - 1, N)) {
                cout << k - 1 << endl;
                break;
            }
        }
        // if (k <= (ll)(ceil(sqrt((double)a[0]) + 0.1)) + 1) {
        //     cout << k << endl;
        //     break;
        // }
        //cout << k << endl;
        
    }

    return 0;
}