Rezultati

Up. imeNalogaJezikRezultatČas oddaje
final-solution-2019 Ocenjevanje univerz C++ 100/100OK 24. apr '19 @ 19:29

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 10/10 3,340 MiB 0,048 s OK
#2 [več] 10/10 3,184 MiB 0,075 s OK
#3 [več] 10/10 3,125 MiB 0,062 s OK
#4 [več] 10/10 3,188 MiB 0,048 s OK
#5 [več] 10/10 3,188 MiB 0,020 s OK
#6 [več] 10/10 3,188 MiB 0,042 s OK
#7 [več] 10/10 3,086 MiB 0,074 s OK
#8 [več] 10/10 3,125 MiB 0,080 s OK
#9 [več] 10/10 3,125 MiB 0,003 s OK
#10 [več] 10/10 3,188 MiB 0,058 s OK

Ocenjevani program (uni.cpp):
#include <bits/stdc++.h>

using namespace std;

#define mp make_pair
#define pb push_back
#define fi first
#define se second


typedef long long ll;
typedef long double ld;

pair<ld, ld> calc(int k, int n, int k1, int n1){
    if(k == k1){
        if(n >= n1)
            return mp(0.0, 1.0);
        else
            return mp(-1.0, -1.0);
    }

//    cout << k << "  " << n << "  " << k1 << " " << n1 << endl << endl; 

    ld p = 1.0 * (n1 - n) / (k - k1);
 //   cout << p << endl;    
    if(k > k1)
        return mp(p, 1.0);

    if(k < k1)
        return mp(0.0, p);
}

pair<ld, ld> inter(pair<ld, ld> a, pair<ld, ld> b){
    return mp(max(a.fi, b.fi), min(a.se, b.se));
}

int main(){
    pair<ld, ld> range = mp(0.0, 1.0);
    int n, a, b, k, m;
    scanf("%d", &m);
    scanf("%d%d", &a, &b);
    k = (a - b); n = b;

    for(int i = 1; i < m; i++){
        int x, y, n1, k1;
        scanf("%d%d", &x, &y);
        k1 = x - y; n1 = y;
        pair<ld, ld> r = calc(k, n, k1, n1);
        range = inter(range, r);
     //   cout << fixed << range.fi << "  " << range.se << endl;
    }

    if(range.fi > range.se)
        cout << "Slabe metrike\n";
    else
        cout << fixed << setprecision(15) << range.fi << " " << 1.0 - range.fi << endl;
}