結果

問題 No.134 走れ!サブロー君
ユーザー ki_ki33ki_ki33
提出日時 2015-01-23 01:29:08
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,316 bytes
コンパイル時間 3,593 ms
コンパイル使用メモリ 74,976 KB
実行使用メモリ 58,220 KB
最終ジャッジ日時 2023-09-05 03:57:10
合計ジャッジ時間 6,789 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 139 ms
55,876 KB
testcase_01 AC 139 ms
56,236 KB
testcase_02 AC 136 ms
55,864 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 138 ms
55,800 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static final int C =  1000000007;
	static final int CY = 1000000000;
	//static boolean MAP[][];
	
	static int N;

	static int M;
	static int MAX = -1;
	//static int tic[][];
	static int X[];
	static int Y[];
	static double W[];
	//static int max;
	static long DP[];
	static int ST[][];
	//static int p[];
	//static ArrayList<HashSet<Integer>> al;
	static TreeMap<Integer, ArrayList<Integer>> hm;
	//static ArrayList<Integer> al;
	//static int a[][];
	//static char[][] ch;
	//static ArrayList<HashMap<Long, Long>> al;
	//static String a[];
	//static String str;

	public static void main(String[] args) {
		//StringBuilder sb = new StringBuilder();
		BufferedInputStream bs = new BufferedInputStream(System.in);
		Scanner sc = new Scanner(bs);
		
		
		
		
		int x0 = sc.nextInt();
		int y0 = sc.nextInt();
		
		N = sc.nextInt();
		
		X = new int[N+1];
		Y = new int[N+1];
		W = new double[N+1];
		
		X[0] = x0;
		Y[0] = y0;
		
		for (int i=1; i <= N; i++) {
			X[i] = sc.nextInt();
			Y[i] = sc.nextInt();
			W[i] = sc.nextDouble();
			
		}
		
		double ans = 0;
		
		long num = 1;
		for (int i=1; i <= N; i++) {
			num *= i;
			ans += W[i];
		}
		
		int ar[] = new int[N+1];
		double sum = 0;
		int x=X[0], y=Y[0];
		for (int i=0; i < N; i++){
			
			int mi = 0;
			if (i==0) {
				double max = 0;
				for (int t=1; t <= N; t++) {
					if (ar[t] != 0) continue;
					if (max < dist(y, x, Y[t], X[t]) || (max == dist(y, x, Y[t], X[t])&& W[t] < W[mi])) {
						max = dist(y, x, Y[t], X[t]) ;
						mi = t;

					}
				}
			} else {
				double min = 1000000;
				for (int t=1; t <= N; t++) {
					if (ar[t] != 0) continue;
					if (min > dist(y, x, Y[t], X[t]) || (min == dist(y, x, Y[t], X[t])&& W[t] < W[mi])) {
						min = dist(y, x, Y[t], X[t]) ;
						mi = t;

					}
				}
			}
			
			double dis = dist(y,x,Y[mi],X[mi]);
			ans += dis * (sum + 100)/120;
			sum += W[mi];
			ar[mi] = 1;
			x = X[mi];
			y = Y[mi];
		}
		ans += dist(y, x, X[0], Y[0]) * (sum + 100)/120;
		
		System.out.println(ans);

	}
	static int dist(int y1, int x1, int y2, int x2) {
		

		return Math.abs(y1 - y2) + Math.abs(x1 - x2);
	}
	

}
0