Rezultati

Up. imeNalogaJezikRezultatČas oddaje
ocetje-interneta-2019 Ocenjevanje univerz C++ 0/100Napačen odgovor (WA) 24. apr '19 @ 19:05

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 0/10 3,664 MiB 0,615 s Napačen odgovor
#2 [več] 0/10 4,313 MiB 3,851 s Napačen odgovor
#3 [več] 10/10 4,434 MiB 0,293 s OK
#4 [več] 0/10 3,766 MiB 1,735 s Napačen odgovor
#5 [več] 0/10 3,266 MiB 0,970 s Napačen odgovor
#6 [več] 0/10 3,688 MiB 0,785 s Napačen odgovor
#7 [več] 10/10 4,438 MiB 2,266 s OK
#8 [več] 10/10 4,535 MiB 2,181 s OK
#9 [več] 10/10 3,246 MiB 0,045 s OK
#10 [več] 0/10 4,020 MiB 0,192 s Napačen odgovor

Ocenjevani program (univerze.cpp):
#include <bits/stdc++.h>
using namespace std;


bool isIncreasing(double a, double b) {
    return a > b;
}

int main() {
    double n;

    double a;
    double b;
    
    cin >> n;
    

    vector<pair<double, double>> v(n);
    for (int i = 0; i < n; i++) {
        cin >> a >> b;
        v[i] = { a, b };
    }
    
    double mid = 0.0;

    double left = 0.0;
    double right = 1.0;
    int counter = 0;
    while (counter < 10000) {
        double ours = v[0].first * mid + v[0].second * (1-mid);
        double solution = 0;

        for (int i = 1; i < n; i++ ) {
            double theirs = v[i].first * mid + v[i].second * (1-mid);
            
            if (theirs > ours) {
               solution++;

               if (isIncreasing(v[i].first, v[i].second)) {
                   right = mid;
                   mid = (right - left) / 2.0;
               } else {
                   left = mid;
                   mid = (right - left) / 2.0;
               }
                break;   
            } else {

            }
        }
        counter++;

        if (solution == 0) {
            cout << mid << endl;
            return 0;
        }


    }
    
    cout << "Slabe metrike" << endl;

    return 0;
}