Rezultati

Up. imeNalogaJezikRezultatČas oddaje
lml-2018 Prehod čez cesto C++ 100/100OK 04. okt '18 @ 18:27

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 1,512 MiB 0,005 s OK
#2 9/9 1,512 MiB 0,005 s OK
#3 9/9 1,484 MiB 0,011 s OK
#4 9/9 1,469 MiB 0,000 s OK
#5 9/9 1,488 MiB 0,000 s OK
#6 9/9 1,469 MiB 0,005 s OK
#7 9/9 1,465 MiB 0,000 s OK
#8 9/9 1,496 MiB 0,000 s OK
#9 9/9 1,469 MiB 0,000 s OK
#10 9/9 1,496 MiB 0,000 s OK
#11 10/10 1,496 MiB 0,000 s OK

Ocenjevani program (Cesta.cpp):
#include <stdio.h>

int main()
{
    double n, m, p, x, v, d;
    scanf("%lf %lf",&n,&m);
    double array[1010][3];

    for(int z = 0; z < m; z++)
    {
        scanf("%lf %lf %lf %lf",&p,&x,&v,&d);
        
        if(v > 0)
        {
            array[z][0] = ((0 - x)/v) - (p - 1) * 10; 
            array[z][1] = (0 - x + d)/v - (p - 1) * 10;
        }
        else
        {
            array[z][0] = ((0 - x)/v) - (p - 1) * 10; 
            array[z][1] = (0 - x - d)/v - (p - 1) * 10;
        }
    }

    double count = 0;

    while(true)
    {
        bool stop = true;

        for(int i = 0; i < m; i++)
        {
            if((count <= array[i][0] && count + 10 >= array[i][0]) || (count >= array[i][0] && count <= array[i][1]))
            {
                stop = false;
                count = array[i][1] + 0.000000001;
                break;
            }    
        }

        if(stop)
        {
            printf("%lf\n",count);
            break;
        }
    }
}