Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jam-2019 Ocenjevanje univerz C++ 100/100OK 24. apr '19 @ 17:41

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 10/10 3,531 MiB 0,026 s OK
#2 [več] 10/10 3,852 MiB 0,043 s OK
#3 [več] 10/10 3,789 MiB 0,054 s OK
#4 [več] 10/10 3,527 MiB 0,044 s OK
#5 [več] 10/10 3,477 MiB 0,015 s OK
#6 [več] 10/10 3,539 MiB 0,032 s OK
#7 [več] 10/10 3,789 MiB 0,072 s OK
#8 [več] 10/10 3,785 MiB 0,054 s OK
#9 [več] 10/10 3,230 MiB 0,016 s OK
#10 [več] 10/10 3,672 MiB 0,043 s OK

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

#define print(x) (cout << #x << " = " << (x) << "\n")

using namespace std;

const double eps = 1e-6;
int n, *a, *b;
double l, r;

int main() {
    cin.sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);

    l = 0;
    r = 1;

    cin >> n;
    a = new int[n];
    b = new int[n];

    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }

    double a1 = a[0], b1 = b[0];
    for (int i = 1; i < n; i++) {
        double a2 = a[i], b2 = b[i];

        if (abs(a1 - a2) < eps && abs(b1 - b2) < eps)
            continue;
        
        if (a1 < a2 + eps && b1 < b2 + eps) {
            l = 1;
            r = 0;
            break;
        }

        if (a1 + eps > a2 && b1 + eps > b2)
            continue;
        
        double x = (b2 - b1) / (a1 - b1 - a2 + b2);
        
        if (a1 > a2) {
            if (x > l)
                l = x;
        } else {
            if (x < r)
                r = x;
        }

        if (l > r + 2 * eps)
            break;
    }

    if (l > r + eps) {
        cout << "Slabe metrike" << "\n";
    } else {
        double x = (l + r) / 2;
        cout << x << " " << 1-x << "\n";
    }

    return 0;
}