結果

問題 No.134 走れ!サブロー君
ユーザー kotatsugamekotatsugame
提出日時 2020-02-28 01:30:39
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 763 bytes
コンパイル時間 745 ms
コンパイル使用メモリ 74,100 KB
実行使用メモリ 5,760 KB
最終ジャッジ日時 2024-04-21 17:16:14
合計ジャッジ時間 1,277 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 3 ms
5,376 KB
testcase_06 AC 4 ms
5,376 KB
testcase_07 AC 7 ms
5,376 KB
testcase_08 AC 13 ms
5,760 KB
testcase_09 AC 12 ms
5,760 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:9:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    9 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
int N,X[14],Y[14];
double W[14];
double dp[1<<14][14];
double sum[1<<14];
main()
{
	cin>>X[0]>>Y[0];
	cin>>N;
	for(int i=0;i++<N;)
	{
		cin>>X[i]>>Y[i]>>W[i];
	}
	N++;
	for(int i=0;i<1<<N;i++)
	{
		for(int j=0;j<N;j++)
		{
			if(!(i>>j&1))sum[i]+=W[j];
			dp[i][j]=1e150;
		}
	}
	dp[1][0]=0;
	for(int i=1;i<1<<N;i++)for(int j=0;j<N;j++)
	{
		double now=sum[i];
		for(int k=0;k<N;k++)
		{
			if(i>>k&1)continue;
			double dist=abs(X[k]-X[j])+abs(Y[k]-Y[j]);
			dp[i|1<<k][k]=min(dp[i|1<<k][k],dp[i][j]+W[k]+dist*(now+100)/120);
		}
	}
	double ans=1e150;
	for(int i=0;i<N;i++)ans=min(ans,dp[(1<<N)-1][i]+(abs(X[i]-X[0])+abs(Y[i]-Y[0]))/1.2);
	cout<<fixed<<setprecision(16)<<ans<<endl;
}
0