Submission #3008310


Source Code Expand

#include <bits/stdc++.h>

using namespace std;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define debug(x) cout << #x << ":" << x << endl;
#define debug2(x) for(auto a : x) cout << a << " "; cout << endl;
#define debug3(x) rep(i, sizeof(x)) cout << x[i] << " "; cout << endl;

vector<pii> around = {MP(1, 0), MP(-1, 0), MP(0, 1), MP(0, -1)};

//------------------------------------------------------

template <typename T, typename U> class dijkstra {
public:

    struct edge {
        T to;
        U cost;
    };

    using P = pair<U, T>;
    map<T, vector<edge> > E;
    map<T, U> d;

    void calc(T s) {
        priority_queue <P, vector<P>, greater<P> > que;
        rep(i, limit) d[i] = LINF; //INF
        que.emplace(U(0), s);
        d[s] = U(0);
        while (!que.empty()) {
            P p = que.top();
            que.pop();
            T v = p.second;
            if (d[v] < p.first) continue;

            for (auto&& e : E[v]) {
                //if (d.find(e.to) == d.end()) d[e.to] = INF;
                if (d[e.to] > d[v] + e.cost) {
                    d[e.to] = d[v] + e.cost;
                    que.emplace(d[e.to], e.to);
                }
            }
        }
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n, m, t;
    cin >> n >> m >> t;
    ll money[n];
    rep(i, n) cin >> money[i];
    dijkstra<ll, ll> ds, ds_rev;

    rep(i, m) {
        ll a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        ds.E[a].push_back({b, c});
        ds_rev.E[b].push_back({a, c});
    }

    ds.calc(0);
    ds_rev.calc(0);

    ll ans = 0;

    rep(i, n) {
        if (ds.d[i] + ds_rev.d[i] > t) continue;
        ans = max(ans, money[i] * (t - ds.d[i] - ds_rev.d[i]));
    }
    cout << ans << endl;
    return 0;
}

Submission Info

Submission Time
Task D - トレジャーハント
User stoq
Language C++14 (GCC 5.4.1)
Score 100
Code Size 2513 Byte
Status AC
Exec Time 396 ms
Memory 35456 KB

Judge Result

Set Name Sample Subtask1 All
Score / Max Score 0 / 0 50 / 50 50 / 50
Status
AC × 3
AC × 20
AC × 42
Set Name Test Cases
Sample 00_example_01.txt, 00_example_02.txt, 00_example_03.txt
Subtask1 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
All 00_example_01.txt, 00_example_02.txt, 00_example_03.txt, 10_rand_01.txt, 10_rand_02.txt, 10_rand_03.txt, 10_rand_04.txt, 10_rand_05.txt, 10_rand_06.txt, 10_rand_07.txt, 10_rand_08.txt, 10_rand_09.txt, 10_rand_10.txt, 10_rand_12.txt, 10_rand_13.txt, 30_max_01.txt, 30_max_02.txt, 30_max_03.txt, 30_max_04.txt, 30_max_05.txt, 30_max_06.txt, 40_corner_01.txt, 40_corner_02.txt, 40_corner_03.txt, 40_corner_04.txt, 50_small_01.txt, 50_small_02.txt, 50_small_03.txt, 50_small_04.txt, 50_small_05.txt, 50_small_06.txt, 50_small_07.txt, 50_small_08.txt, 50_small_09.txt, 50_small_10.txt, 60_hand_01.txt, 60_hand_02.txt, 60_hand_03.txt, 60_hand_04.txt, 70_max_01.txt, 70_max_02.txt, 70_max_03.txt
Case Name Status Exec Time Memory
00_example_01.txt AC 53 ms 12800 KB
00_example_02.txt AC 58 ms 12800 KB
00_example_03.txt AC 55 ms 12800 KB
10_rand_01.txt AC 64 ms 13312 KB
10_rand_02.txt AC 102 ms 16384 KB
10_rand_03.txt AC 64 ms 13824 KB
10_rand_04.txt AC 54 ms 12928 KB
10_rand_05.txt AC 64 ms 13568 KB
10_rand_06.txt AC 63 ms 13056 KB
10_rand_07.txt AC 70 ms 13312 KB
10_rand_08.txt AC 59 ms 12928 KB
10_rand_09.txt AC 68 ms 13184 KB
10_rand_10.txt AC 60 ms 12800 KB
10_rand_12.txt AC 174 ms 17540 KB
10_rand_13.txt AC 163 ms 17532 KB
30_max_01.txt AC 272 ms 21348 KB
30_max_02.txt AC 359 ms 24908 KB
30_max_03.txt AC 195 ms 19148 KB
30_max_04.txt AC 220 ms 28800 KB
30_max_05.txt AC 208 ms 28800 KB
30_max_06.txt AC 227 ms 28800 KB
40_corner_01.txt AC 392 ms 35456 KB
40_corner_02.txt AC 391 ms 35456 KB
40_corner_03.txt AC 385 ms 35456 KB
40_corner_04.txt AC 396 ms 35456 KB
50_small_01.txt AC 54 ms 12800 KB
50_small_02.txt AC 53 ms 12800 KB
50_small_03.txt AC 54 ms 12800 KB
50_small_04.txt AC 52 ms 12800 KB
50_small_05.txt AC 55 ms 12928 KB
50_small_06.txt AC 53 ms 12928 KB
50_small_07.txt AC 53 ms 12800 KB
50_small_08.txt AC 50 ms 12800 KB
50_small_09.txt AC 52 ms 12800 KB
50_small_10.txt AC 52 ms 12800 KB
60_hand_01.txt AC 54 ms 12800 KB
60_hand_02.txt AC 52 ms 12800 KB
60_hand_03.txt AC 55 ms 12800 KB
60_hand_04.txt AC 51 ms 12800 KB
70_max_01.txt AC 78 ms 14464 KB
70_max_02.txt AC 78 ms 14464 KB
70_max_03.txt AC 79 ms 14464 KB