結果
| 問題 |
No.134 走れ!サブロー君
|
| コンテスト | |
| ユーザー |
kuuso1
|
| 提出日時 | 2015-01-23 00:15:14 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,966 bytes |
| コンパイル時間 | 2,332 ms |
| コンパイル使用メモリ | 115,512 KB |
| 実行使用メモリ | 29,416 KB |
| 最終ジャッジ日時 | 2024-06-23 00:36:28 |
| 合計ジャッジ時間 | 2,379 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 1 WA * 14 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections;
using System.Collections.Generic;
class TEST{
static void Main(){
Sol mySol =new Sol();
mySol.Solve();
}
}
class Sol{
public void Solve(){
double Inf=1e16;
double[][] dp=new double[1<<N][];
for(int i=0;i<(1<<N);i++){
dp[i]=new double[N];
for(int j=0;j<N;j++)dp[i][j]=Inf;
}
double[] Sum=new double[1<<N];
double tot=0;
for(int i=0;i<N;i++)tot+=W[i];
for(int i=0;i<(1<<N);i++){
Sum[i]=tot;
for(int j=0;j<N;j++){
if(((i>>j)&1)>0)Sum[i]-=W[j];
}
}
for(int j=0;j<N;j++){
dp[1<<j][j]=W[j]+(Math.Abs(X[j]-X0)+Math.Abs(Y[j]-Y0))*(tot+100)/120;
}
for(int s=0;s<(1<<N);s++){
for(int j=0;j<N;j++){
if(dp[s][j]==Inf)continue;
for(int k=0;k<N;k++){
if(((s>>k)&1)>0)continue;
dp[s|(1<<k)][k]=Math.Min(dp[s|(1<<k)][k],dp[s][j]+W[k]+(Math.Abs(X[k]-Y[j])+Math.Abs(Y[k]-Y[j]))*(Sum[s]+100)/120);
}
}
}
double Ans=Inf;
for(int i=0;i<N;i++){
Ans=Math.Min(Ans,dp[(1<<N)-1][i]+(Math.Abs(X[i]-X0)+Math.Abs(Y[i]-Y0))*(0+100)/120);
}
Console.WriteLine(Ans);
}
int X0,Y0;
int N;
int[] X,Y;
double[] W;
public Sol(){
var d=ria();
X0=d[0];Y0=d[1];
N=ri();
X=new int[N];
Y=new int[N];
W=new double[N];
for(int i=0;i<N;i++){
var dd=rsa();
X[i]=int.Parse(dd[0]);
Y[i]=int.Parse(dd[1]);
W[i]=double.Parse(dd[2]);
}
}
static String rs(){return Console.ReadLine();}
static int ri(){return int.Parse(Console.ReadLine());}
static long rl(){return long.Parse(Console.ReadLine());}
static double rd(){return double.Parse(Console.ReadLine());}
static String[] rsa(){return Console.ReadLine().Split(' ');}
static int[] ria(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>int.Parse(e));}
static long[] rla(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>long.Parse(e));}
static double[] rda(){return Array.ConvertAll(Console.ReadLine().Split(' '),e=>double.Parse(e));}
}
kuuso1