Rezultati

Up. imeNalogaJezikRezultatČas oddaje
scnm1-2018 Prehod čez cesto Java 100/100OK 04. okt '18 @ 17:12

Test Točke Porabljen spomin Porabljen čas Status
#1 9/9 41,148 MiB 0,000 s OK
#2 9/9 40,512 MiB 0,000 s OK
#3 9/9 41,094 MiB 0,000 s OK
#4 9/9 33,656 MiB 0,000 s OK
#5 9/9 33,434 MiB 0,000 s OK
#6 9/9 33,594 MiB 0,000 s OK
#7 9/9 37,363 MiB 0,000 s OK
#8 9/9 35,125 MiB 0,000 s OK
#9 9/9 36,715 MiB 0,000 s OK
#10 9/9 33,918 MiB 0,000 s OK
#11 10/10 35,145 MiB 0,000 s OK

Ocenjevani program (n1.java):
import java.util.*;
import java.io.*;

public class n1 {

	public static void main(String[] args) throws Exception {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer(in.readLine());
		int ceste=Integer.parseInt(st.nextToken());
		int inter=Integer.parseInt(st.nextToken());
		double[]left=new double[inter];
		double[]right=new double[inter];
		for(int i=0;i<inter;i++) {
			st=new StringTokenizer(in.readLine());
			int n=Integer.parseInt(st.nextToken());
			int x0=Integer.parseInt(st.nextToken());
			int v=Integer.parseInt(st.nextToken());
			int d=Integer.parseInt(st.nextToken());
			if(v>0) {
				v*=-1;
				x0*=-1;
			}
			v*=-1;//hitrost v levo
			//vsi so na desni
			left[i]=((double)x0/v)-10*n;
			right[i]=((double)x0+d)/v-10*(n-1);
		}
		double best=0;
		double eps=Math.pow(10.0, -6.2);
		while(true) {
			double pb=best;
			for(int i=0;i<inter;i++) {
				if(best+eps<left[i]||best-eps>right[i]) {
					
				}
				else{
					best=right[i]+eps/2;//mogoče?
				}
			}
			if(pb==best) {
				break;
			}
		}
		System.out.println(best);
	}

}