結果

問題 No.134 走れ!サブロー君
ユーザー maine_honzukimaine_honzuki
提出日時 2020-05-19 18:28:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 936 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 169,788 KB
実行使用メモリ 10,400 KB
最終ジャッジ日時 2024-04-09 22:21:44
合計ジャッジ時間 9,442 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 11 ms
6,944 KB
testcase_05 AC 100 ms
6,944 KB
testcase_06 AC 1,167 ms
6,940 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int X_0, Y_0, N;
    cin >> X_0 >> Y_0 >> N;
    vector<int> X(N + 2), Y(N + 2);
    vector<double> W(N + 2);
    double total = 0;
    for (int i = 1; i <= N; i++) {
        cin >> X[i] >> Y[i] >> W[i];
        X[i] -= X_0;
        Y[i] -= Y_0;
        total += W[i];
    }
    X[N + 1] = 0;
    Y[N + 1] = 0;

    double ans = 1e30;

    vector<int> A(N + 2);
    iota(A.begin(), A.end(), 0);

    auto t = [&](int i, int j, double w) {
        int dist = abs(X[i] - X[j]) + abs(Y[i] - Y[j]);
        return dist * (w + 100) / 120;
    };

    do {
        double w = total;
        double tm = 0;
        for (int i = 0; i <= N; i++) {
            tm += t(A[i], A[i + 1], w);
            w -= W[A[i + 1]];
        }
        ans = min(ans, tm);
    } while (next_permutation(A.begin() + 1, A.end() - 1));

    cout << fixed << setprecision(10) << ans + total << endl;
}
0