九度論壇-1002

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		int p; //the full-mark
		int t; //the tolerance
		int g1,g2,g3,gj;//the scores
		
		Scanner scanner = new Scanner(System.in);
		
		while(scanner.hasNext()){
			p = scanner.nextInt();
			t = scanner.nextInt();
			g1 = scanner.nextInt();
			g2 = scanner.nextInt();
			g3 = scanner.nextInt();
			gj = scanner.nextInt();
			
			if(Math.abs(g1-g2)<=t){
				System.out.println((g1+g2)/2.0);
			}else if((Math.abs(g3-g1)<=t)||(Math.abs(g3-g2)<=t)){
				if((Math.abs(g3-g1)<=t)&&(Math.abs(g3-g2)<=t)){
					int max1 ;
					int max2 ;
					
					if(g1<g2){
						max1 = g1;
					}else{
						max1 = g2;
					}
					
					if(g1<g3){
						max2 = g3;
					}else{
						max2 = g1;
					}
					
					if(max1>max2){
						System.out.println(max1);
					}else{
						System.out.println(max2);
					}
				}else{
					int avg1 = (g1+g3)/2;
					int avg2 = (g2+g3)/2;
					
					if(Math.abs(g3-avg1) < Math.abs(g3-avg2)){
						System.out.println((g1+g3)/2.0);
					}else{
						System.out.println((g2+g3)/2.0);
					}
				}
				
			}else if((Math.abs(g3-g1)>t)&&(Math.abs(g3-g2)>t)){
				System.out.println(gj + ".0");
			}
			
			
		}
	}

}
相關文章
相關標籤/搜索