ANEO Sponsored Puzzle discussion


#133

Hello,
First and foremost, The problem is really interesting and keep on innovating.

Although, I was able to pass only 7 test cases, I’m curious to know the algorithm.
So, can you please tell me the way you have constructed.

Keep Innovating

Thank you

Here’s my code; I someone can help me to figure out the bug, please!

// the program below works fine 
// for all test cases except 
// Test Cases: 6,9,10
// Reason: for 6; output: 48 but answer:49
// Reason: for 9; output: 0 but answer:6
// Reason: for 10; output: 88 but answer: 74

import sys
import math

//max_speed_original km/h
max_speed_o = int(input())
light_count = int(input())

// max_speed m/s
max_speed = max_speed_o * 5/18 

dur = []  //duration
dist = [] //distance

// store the values in a list
for i in range(light_count):
    distance, duration = [int(j) for j in input().split()]
    
    dur.append(duration)
    dist.append(distance)

// min time for the closest light
t_min_i = dist[0]/max_speed

// approx int val
t = math.floor(t_min_i)

while True:
    isGreen = False
    
    #iterate through each
    for i in range(light_count):
        
        // using point slope method to find the intercept
        if int((dist[i]/dist[0]*t)//dur[i]) % 2 == 0:
            isGreen = True
        else:
            isGreen = False
            break

    if isGreen:break
    t += 1
    
if isGreen:
    
    //s = speed
    s = (dist[0]/t)
    
    // check if speed > max_speed m/s
    s = max_speed if s>max_speed else s
    
    //print('Floor km/h:',math.floor(s* (18/5)))
    
    s = math.floor(s* (18/5))
    
    // check if speed > max_speed km/h
    s = max_speed_o if s>max_speed_o else s
    
    
    print(s)    
//-----------End -----------

#134

well, from third attempt I hacked through it: the problem is that condition “you can’t cross light on the second it turns red” does not define precision of time, i.e. if you reach light at e.g. time=14.9999998s tests could count it as 15s. Maybe it is just implementation problem of the tests.
In fact, it seems that actual challenge is not (only) to solve the task, but to get over the non precise requirements :wink:


#135

No, the challenge is to find how to solve it without rouding issues so you don’t accuse the game instead of accusing your solution.


#136

Thanks. I didn’t read carefully and got only 2 tests right because I thought the distance to next light was in the same unit as the speed.


#137

I’m confused, I can’t solve the second testcase. I have tried doing unit conversions, which just give me the exact same result. I exported some variables:
Distance: 200
Speed Limit: 50
Arrival Time: 4
Duration: 10
Ideal Speed: 50
It says expected was 36km/h. But if the Duration was 10 seconds, and I get there in 4, how would 36 be considered the answer?


#138

4 seconds to travel 200 meters.

If I’m not mistaken, that’s 50 meters per second. So 3 km / minute. So 180km / hour

That’s fast :smiley:


#139

I have the same answer.


#140

Hi, I am new in this site. I want working with this site but i cannot becouse i am not understanding. please help me. thenks.


#141

You are given:
Speed - X Killometer per Hour
Distance - Meters
Duration - Seconds
So for example 10Km/H is 2.7778 ms so we will travel 200 meters in 71 Seconds…
Always read what are you given, or you will stuck with wrong data.


#142

so my program includes this specific calculation: 1.2/6.0/(1/180). When i punch it into a calculator it turns out to be 36 (which means my program works). However on codingame (I’ve tried on another puzzle), it outputs infinity instead and now I’m stuck on the light string test while having passed all but another test. Is this a problem on my side?


#143

Hello! Need your help. Who knows what example 10 test?


#144

With the expression (1/180) you are dividing two integers, and the result will also be an integer. (1/180) will evaluate to an integer value 0.

Replace it with (1.0/180.0) and it will probably work.


#145

how can i ask my question
i have a doubt in this puzzle
if speed is already given what is needed to be done


#146

i don’t understand anything


#147

the puzzle says to output the maximum speed but the outputs are the same or less than the riginal speed pls explain