Rezultati

Up. imeNalogaJezikRezultatČas oddaje
rektifikatorji-2018 Prehod čez cesto Python 3 0/100Napaka med izvajanjem / ob izhodu (RTE) 04. okt '18 @ 18:54

Test Točke Porabljen spomin Porabljen čas Status
#1 0/9 8,777 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 34, in <module>
    p, x, v, d = cin()
  File "source.py3", line 4, in cin
    return input().split()
EOFError: EOF when reading a line
#2 0/9 8,723 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 34, in <module>
    p, x, v, d = cin()
  File "source.py3", line 4, in cin
    return input().split()
EOFError: EOF when reading a line
#3 9/9 8,730 MiB 0,000 s OK
#4 9/9 8,594 MiB 0,000 s OK
#5 9/9 8,516 MiB 0,000 s OK
#6 0/9 8,594 MiB 0,000 s Program je končal z neničelno kodo
Stderr:
Traceback (most recent call last):
  File "source.py3", line 34, in <module>
    p, x, v, d = cin()
  File "source.py3", line 4, in cin
    return input().split()
EOFError: EOF when reading a line
#7 9/9 8,586 MiB 0,000 s OK
#8 9/9 8,594 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,527 MiB 0,000 s OK

Ocenjevani program (main.py):
import sys

def cin():
    return input().split()

def merge_intervals(intervals):
    intervals = sorted(intervals, key=lambda k: k[0])
    intervals_merged = []
    i = 0
    l = len(intervals)
    while i < l:
        start = intervals[i][0]
        end = intervals[i][1]

        i += 1
        while i < l and intervals[i][0] <= end:
            if intervals[i][1] > end:
                end = intervals[i][1]
            i += 1

        intervals_merged.append([start, end])
    return intervals_merged

N, M = cin()
N = int(N)
M = int(M)

intervals = []

#
# build intervals
m = 0
while m < M:
    p, x, v, d = cin()
    p = int(p)
    x = float(x)
    v = float(v)
    d = float(d)

    # vozi desno proti x
    if x <= 0.0 and v > 0:
        x += abs(v)*10.0*(p-1)
    # vozi levo proti x
    elif x >= 0.0 and v < 0:
        x -= abs(v) * 10.0*(p-1)
    else:
        continue

    start = abs(x) / abs(v)
    end = start + d / abs(v)
    intervals.append([start, end])
    m += 1

intervals = merge_intervals(intervals)
intervals.append([sys.float_info.max, sys.float_info.max])
janezek_time = N*10.0

# check for first item
if intervals[0][0] > janezek_time:
    print(0.0)
else:
    i = 0
    while True:
        diff = intervals[i+1][0]-intervals[i][1]
        if diff > janezek_time:
            print(intervals[i][1])
            break
        i += 1