結果

問題 No.2712 Play more!
ユーザー shihakashihaka
提出日時 2024-03-31 14:54:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 4,047 bytes
コンパイル時間 4,784 ms
コンパイル使用メモリ 272,040 KB
実行使用メモリ 814,904 KB
最終ジャッジ日時 2024-03-31 14:54:49
合計ジャッジ時間 14,901 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
18,976 KB
testcase_01 AC 36 ms
19,104 KB
testcase_02 AC 11 ms
18,976 KB
testcase_03 AC 148 ms
29,208 KB
testcase_04 WA -
testcase_05 AC 36 ms
19,104 KB
testcase_06 AC 36 ms
19,104 KB
testcase_07 AC 38 ms
19,232 KB
testcase_08 AC 38 ms
19,232 KB
testcase_09 AC 43 ms
19,232 KB
testcase_10 WA -
testcase_11 AC 266 ms
53,924 KB
testcase_12 AC 136 ms
25,056 KB
testcase_13 AC 312 ms
86,556 KB
testcase_14 AC 99 ms
20,248 KB
testcase_15 AC 221 ms
37,496 KB
testcase_16 AC 923 ms
283,348 KB
testcase_17 AC 1,189 ms
283,304 KB
testcase_18 AC 195 ms
37,340 KB
testcase_19 AC 410 ms
86,504 KB
testcase_20 AC 303 ms
53,944 KB
testcase_21 AC 1,118 ms
283,300 KB
testcase_22 AC 189 ms
37,552 KB
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define overload5(a,b,c,d,e,name,...) name
#define overload4(a,b,c,d,name,...) name
#define overload3(a,b,c,name,...) name
#define rep1(n) for(ll i=0;i<n;++i)
#define rep2(i,n) for(ll i=0;i<n;++i)
#define rep3(i,a,b) for(ll i=a;i<b;++i)
#define rep4(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) overload4(__VA_ARGS__,rep4,rep3,rep2,rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i=n;i--;)
#define rrep2(i,n) for(ll i=n;i--;)
#define rrep3(i,a,b) for(ll i=a;i>=(b);--i)
#define rrep4(i,a,b,c) for(ll i=a;i>=(b);i-=c)
#define rrep(...) overload4(__VA_ARGS__,rrep4,rrep3,rrep2,rrep1)(__VA_ARGS__)
#define ALL1(i) begin(i),end(i)
#define ALL2(i,a) begin(i),begin(i)+a
#define ALL3(i,a,b) begin(i)+a,begin(i)+b
#define ALL(...) overload3(__VA_ARGS__,ALL3,ALL2,ALL1)(__VA_ARGS__)
#define sz(a) ((ll)a.size())
#define lb(v, x) distance((v).begin(), lower_bound(ALL(v), (x)))
#define lbg(v, x) distance((v).begin(), lower_bound(ALL(v), (x), greater{}))
#define ub(v, x) distance((v).begin(), upper_bound(ALL(v), (x)))
#define ubg(v, x) distance((v).begin(), upper_bound(ALL(v), (x), greater{}))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(rbegin(v),rend(v))
#define REV(v) reverse(ALL(v))
using ll = long long;
using P = pair<ll,ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vc = vector<char>;
using vvc = vector<vc>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vvvvi = vector<vvvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vvvvl = vector<vvvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vp = vector<P>;
using vvp = vector<vp>;
using vs = vector<string>;
using vvs = vector<vs>;
constexpr ll zero=0;
constexpr ll LINF=2e18;
constexpr ll INF=1001001001;
constexpr int dx[8]={-1,0,1,0,-1,1,1,-1};
constexpr int dy[8]={0,1,0,-1,1,1,-1,-1};
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {return ((a < b) ? (a = b, true) : (false));}
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {return ((a > b) ? (a = b, true) : (false));}
template<typename T> bool inRange(const T &x, const T &l, const T &r) {return l <= x & x < r;}
constexpr ll div_floor(ll x, ll y) {assert(y != 0); return (x - ((x%y+y)%y)) / y;}
constexpr ll div_ceil(ll x, ll y) {assert(y != 0); return (x + ((y-x%y)%y)) / y;}
using mint = modint998244353;
vvl To(ll n, ll m, bool directed = false) {
    vvl to(n);
    while(m--) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        to[u].push_back(v);
        if(!directed) to[v].push_back(u);
    }
    return to;
}
vvp ToW(ll n, ll m, bool directed = false) {
    vvp to(n);
    while(m--) {
        ll u, v, w;
        cin >> u >> v >> w;
        u--, v--;
        to[u].emplace_back(v, w);
        if(!directed) to[v].emplace_back(u, w);
    }
    return to;
}

ll MAX_V = 500005;
// first:to, second:cost
vl a;
vector<vector<P>> to(MAX_V);
vector<ll> dist(MAX_V,-LINF);
ll cnt = 0;

void dijkstra(ll s) {
    priority_queue<P> que;
    dist[s] = a[0];
    que.emplace(a[0], s);
    
    while(!que.empty()) {
        cnt++;
        if(cnt > 1000000) {
            return ;
        }
        P p = que.top(); que.pop();
        ll v = p.second;
        if(dist[v] > p.first)
            continue;
        for(ll i = 0; i < to[v].size(); i++) {
            P e = to[v][i];
            if(dist[e.first] < dist[v] + a[e.first] - e.second) {
                dist[e.first] = dist[v] + a[e.first] - e.second;
                que.emplace(dist[e.first], e.first);
            }
        }
    }
}

int main() {
    ll n, m;
    cin >> n >> m;
    a.resize(n);
    rep(i,n) cin >> a[i];
    vl x(m), y(m), z(m);
    rep(i,m) cin >> x[i] >> y[i] >> z[i];

    rep(i,m) {
        x[i]--; y[i]--;
        to[x[i]].push_back({y[i], z[i]});
    }
    
    dijkstra(0);

    if(cnt > 1000000) {
        cout << "inf" << endl;
    }
    else {
        cout << dist[n-1] << endl;
    }



    return 0;
}
0