結果

問題 No.134 走れ!サブロー君
ユーザー 沙耶花沙耶花
提出日時 2021-10-27 23:29:08
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 18 ms / 5,000 ms
コード長 943 bytes
コンパイル時間 4,551 ms
コンパイル使用メモリ 258,212 KB
実行使用メモリ 6,088 KB
最終ジャッジ日時 2024-04-16 12:47:08
合計ジャッジ時間 5,256 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 4 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 9 ms
5,376 KB
testcase_08 AC 18 ms
6,088 KB
testcase_09 AC 17 ms
5,888 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 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000

int main(){
	
	vector<double> x(1),y(1),w(1);
	cin>>x[0]>>y[0];
	w[0] = 0.0;
	int n;
	cin>>n;
	
	x.resize(n+1),y.resize(n+1),w.resize(n+1);
	double S = 0.0;
	rep(i,n){
		cin>>x[i+1]>>y[i+1]>>w[i+1];
		S += w[i+1];
	}
	n++;
	vector dp(1<<n,vector<double>(n,1e30));
	dp[0][0] = 0.0;
	
	rep(i,1<<n){
		rep(j,n){
			if(dp[i][j]>1e20)continue;
			double W = S;
			rep(k,n){
				if((i>>k)&1)W -= w[k];
			}
			rep(k,n){
				if((i>>k)&1)continue;
				int ni = i | (1<<k);
				int nj = k;
				double nv = dp[i][j];
				nv += (W+100.0)/120.0 * (abs(x[k]-x[j]) + abs(y[k]-y[j]));
				dp[ni][nj] = min(dp[ni][nj],nv);
			}
		}
	}
	
	double ans = dp.back()[0];
	ans += S;
	
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
}
0