結果

問題 No.134 走れ!サブロー君
ユーザー koyoprokoyopro
提出日時 2015-10-25 13:12:25
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 1,258 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 161,672 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 18:04:00
合計ジャッジ時間 1,845 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 2 ms
5,376 KB
testcase_06 AC 3 ms
5,376 KB
testcase_07 AC 4 ms
5,376 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 7 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 1 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
struct P { int x, y; double w; P(){}; P(int _x, int _y): x(_x), y(_y){}; };
int kyotoDist(P p, P q) {
    return abs(p.x - q.x) + abs(p.y - q.y);
}

int N,T;
double dp[14][1<<14];
vector<P> ps;
int X[15], Y[15], W[15];
double speed(double w) {
    return (w + 100.0) / 120.0;
}
signed main()
{
    P s;
    cin >> s.x >> s.y;
    cin >> N;
    ps.resize(N);
    REP(i,N) cin >> ps[i].x >> ps[i].y >> ps[i].w;
    REP(i,N) REP(j,1<<N) dp[i][j] = 1e9;
    double w = 0;
    REP(i,N) w += ps[i].w;
    REP(i,N) {
        dp[i][1<<i] = ps[i].w + speed(w) * kyotoDist(s, ps[i]);
    }
    REP(i,1<<N) {
        double weight = 0;
        REP(j,N) if (!(i & 1<<j)) weight += ps[j].w;
        REP(j,N) REP(k,N) {
            if (j == k) continue;
            if (!(i & 1<<j)) continue;
            if (!(i & 1<<k)) continue;
            double w = weight + ps[j].w;
            double t = ps[j].w + speed(w) * kyotoDist(ps[j], ps[k]);
            dp[j][i] = min(dp[j][i], dp[k][i-(1<<j)] + t);
        }
    }
    double mint = 1e9;
    REP(i,N) {
        mint = min(mint, dp[i][(1<<N)-1] + speed(0) * kyotoDist(s, ps[i]));
    }
    printf("%.14f\n", mint);
    return 0;
}
0