Rezultati

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

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

Ocenjevani program (pivo.cpp):
#include <iostream>
#include <algorithm>
#include <array>
#include <complex>
#include <cmath>
#include <functional>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <utility>

using namespace std;

typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;

bool ok(int k, int a) {
    if (a % k == 0) return true;
    int r = a / k + 1;
    int m = r*k - a;
    return m <= r;
}

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin >> n;
    
    vi st(n);
    int m = numeric_limits<int>::max();
    for (int i = 0; i < n; ++i) {
        cin >> st[i];
        m = min(m, st[i]);
    }
    
    for (int i = 1; ; ++i) {
        int k = m / i + 1;
        bool gut = true;
        for (int x : st) {
            if (!ok(k, x)) {
                gut = false;
                break;
            }
        }
        if (gut) {
            cout << k << endl;
            return 0;
        }
        
        if (m % i == 0) {
            int k = m / i;
            bool gut = true;
            for (int x : st) {
                if (!ok(k, x)) {
                    gut = false;
                    break;
                }
            }
            if (gut) {
                cout << k << endl;
                return 0;
            }
        }
    }
    
    
    return 0;
}