結果

問題 No.134 走れ!サブロー君
ユーザー pekempeypekempey
提出日時 2015-08-21 10:30:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 5,000 ms
コード長 1,052 bytes
コンパイル時間 1,505 ms
コンパイル使用メモリ 160,932 KB
実行使用メモリ 5,504 KB
最終ジャッジ日時 2024-04-22 18:03:53
合計ジャッジ時間 2,342 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,504 KB
testcase_01 AC 4 ms
5,376 KB
testcase_02 AC 3 ms
5,376 KB
testcase_03 AC 4 ms
5,376 KB
testcase_04 AC 4 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,504 KB
testcase_08 AC 16 ms
5,376 KB
testcase_09 AC 16 ms
5,376 KB
testcase_10 AC 3 ms
5,504 KB
testcase_11 AC 3 ms
5,376 KB
testcase_12 AC 4 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 4 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;

double dp[1 << 14][14];

int main() {
	double x0, y0;
	cin >> x0 >> y0;
	int N;
	cin >> N;
	vector<double> X(N + 1), Y(N + 1), W(N + 1);
	rep (i, N) cin >> X[i] >> Y[i] >> W[i];
	X[N] = x0;
	Y[N] = y0;
	W[N] = 0;
	N++;
	fill_n((double *)dp, sizeof(dp) / sizeof(dp[0][0]), inf);

	dp[0][N - 1] = 0;
	rep (i, 1 << N) {
		double w = 0;
		rep (j, N) {
			if (!(i & 1 << j)) {
				w += W[j];
			}
		}
		rep (j, N) {
			rep (k, N) {
				if (!(i & 1 << k)) {
					double dist = abs(X[k] - X[j]) + abs(Y[k] - Y[j]);
					double cost = (w + 100) / 120;
					dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + dist * cost + W[k]);
				}
			}
		}
	}

	double ans = dp[(1 << N) - 1][N - 1];
	printf("%.20f\n", ans);

    return 0;
}
0