結果
| 問題 |
No.134 走れ!サブロー君
|
| コンテスト | |
| ユーザー |
ki_ki33
|
| 提出日時 | 2015-01-23 01:29:08 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,316 bytes |
| コンパイル時間 | 2,434 ms |
| コンパイル使用メモリ | 79,192 KB |
| 実行使用メモリ | 56,480 KB |
| 最終ジャッジ日時 | 2024-06-23 00:38:30 |
| 合計ジャッジ時間 | 5,388 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 11 |
ソースコード
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);
}
}
ki_ki33