Rezultati

Up. imeNalogaJezikRezultatČas oddaje
muzik-2018 Prehod čez cesto Python 3 100/100OK 04. okt '18 @ 19:46

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 8,688 MiB 0,000 s OK
#2 9/9 8,645 MiB 0,000 s OK
#3 9/9 8,656 MiB 0,000 s OK
#4 9/9 8,668 MiB 0,000 s OK
#5 9/9 8,668 MiB 0,000 s OK
#6 9/9 8,590 MiB 0,000 s OK
#7 9/9 8,465 MiB 0,000 s OK
#8 9/9 8,523 MiB 0,000 s OK
#9 9/9 8,676 MiB 0,000 s OK
#10 9/9 8,672 MiB 0,000 s OK
#11 10/10 8,680 MiB 0,000 s OK

Ocenjevani program (cesta.py):
import sys
import math

sys.setrecursionlimit(10 ** 9)

# sys.stdin = open("a.in")

inp = sys.stdin

N, M = map(int, inp.readline().split())

data = []


def sgn(x):
    if x > 0:
        return 1
    return -1


def calculate(p, x, v, d):
    x = x + v * (p - 1) * 10
    if v > 0:
        if x > d:
            return
        elif 0 <= x <= d:
            data.append([0, (d - x) / v])
        else:
            data.append([-x / v, (-x + d) / v])
    if v < 0:
        if x < -d:
            return
        elif -d <= x <= 0:
            data.append([0, (d + x) / (-v)])
        else:
            data.append([x/(-v), (x+d)/(-v)])


for j in range(M):
    p, x, v, d = map(int, inp.readline().split())
    calculate(p, x, v, d)

data.sort()
# print(data)
start = 0.0
end = 0.0
for (b, e) in data:
    if b >= end:
        if b - end > 10:
            print(end)
            break
        start = b
        end = e
    else:
        end = max(end, e)
else:
    print(end)