結果
問題 | No.2712 Play more! |
ユーザー | Iroha_3856 |
提出日時 | 2024-03-31 14:11:11 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 355 ms / 2,000 ms |
コード長 | 4,760 bytes |
コンパイル時間 | 6,088 ms |
コンパイル使用メモリ | 288,260 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-09-30 23:46:10 |
合計ジャッジ時間 | 8,695 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,816 KB |
testcase_02 | AC | 2 ms
6,816 KB |
testcase_03 | AC | 2 ms
6,816 KB |
testcase_04 | AC | 2 ms
6,820 KB |
testcase_05 | AC | 2 ms
6,820 KB |
testcase_06 | AC | 2 ms
6,820 KB |
testcase_07 | AC | 72 ms
6,820 KB |
testcase_08 | AC | 72 ms
6,820 KB |
testcase_09 | AC | 73 ms
6,820 KB |
testcase_10 | AC | 2 ms
6,820 KB |
testcase_11 | AC | 58 ms
6,820 KB |
testcase_12 | AC | 210 ms
6,820 KB |
testcase_13 | AC | 57 ms
6,816 KB |
testcase_14 | AC | 145 ms
6,820 KB |
testcase_15 | AC | 355 ms
6,820 KB |
testcase_16 | AC | 21 ms
6,820 KB |
testcase_17 | AC | 6 ms
6,820 KB |
testcase_18 | AC | 23 ms
6,816 KB |
testcase_19 | AC | 10 ms
6,816 KB |
testcase_20 | AC | 87 ms
6,820 KB |
testcase_21 | AC | 33 ms
6,820 KB |
testcase_22 | AC | 207 ms
6,820 KB |
testcase_23 | AC | 11 ms
6,816 KB |
testcase_24 | AC | 28 ms
6,820 KB |
testcase_25 | AC | 6 ms
6,820 KB |
testcase_26 | AC | 27 ms
6,820 KB |
testcase_27 | AC | 77 ms
6,816 KB |
testcase_28 | AC | 62 ms
6,820 KB |
testcase_29 | AC | 33 ms
6,820 KB |
testcase_30 | AC | 266 ms
6,816 KB |
testcase_31 | AC | 86 ms
6,820 KB |
testcase_32 | AC | 80 ms
6,816 KB |
testcase_33 | AC | 2 ms
6,820 KB |
testcase_34 | AC | 2 ms
6,820 KB |
testcase_35 | AC | 2 ms
6,816 KB |
ソースコード
//#define _GLIBCXX_DEBUG #include<bits/stdc++.h> using namespace std; //AtCoder-Library #if __has_include(<atcoder/all>) #include<atcoder/all> using namespace atcoder; using mint = atcoder::modint998244353; #endif //PBDS-tree #if __has_include(<ext/pb_ds/assoc_container.hpp>) #include<ext/pb_ds/assoc_container.hpp> #include<ext/pb_ds/tree_policy.hpp> #include<ext/pb_ds/tag_and_trait.hpp> using namespace __gnu_pbds; template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; //tree.find_by_order(k) = tree[k] (0-indexed) //tree.order_of_key(k) = tree.lower_bound(k) - tree.begin() //Note: Can only be used for non-multiple sets. #endif #define vec vector #define ll long long #define ull unsigned long long #define vi vec<int> #define vll vec<ll> #define vb vec<bool> #define vvi vec<vi> #define vvll vec<vll> #define vvb vec<vb> #define vvvi vec<vvi> #define vvvll vec<vvll> #define vvvb vec<vvb> #define pii pair<int, int> #define pll pair<ll, ll> #define pli pair<ll, int> #define pq priority_queue template<class T> using spq = priority_queue<T, vector<T>, greater<T>>; #define eb emplace_back #define pb push_back #define spa " " #define all(x) (x).begin(), (x).end() #define rep(i, l, r) for (int i=(int)(l); i<(int)(r); i++) #define REP(i, l, r) for (int i=(int)(l); i<=(int)(r); i++) #define siz(x) (int)x.size() template<class T>bool chmax(T &a, T b) { if (a<b) { a=b; return 1; } return 0; } template<class T>bool chmin(T &a, T b) { if (b<a) { a=b; return 1; } return 0; } //Slice(A, l, r) = A[l, r) template<class T> vector<T> Slice(vector<T> A, int l, int r) { assert(0 <= l && l < (int)A.size()); assert(0 <= r && r <= (int)A.size()); vector<T> ret; for (int i = l; i<r; i++) ret.push_back(A[i]); return ret; } //Slice(S, l, r) = S[l, r) string Slice(string s, int l, int r) { assert(0 <= l && l < (int)s.size()); assert(0 <= r && r <= (int)s.size()); string ret; for (int i = l; i<r; i++) ret += s[i]; return ret; } ll Ceil(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return (abs(x) + abs(y)-1)/abs(y); } else { return -(abs(x)/abs(y)); } } ll Floor(ll x, ll y) { assert(y != 0); if ((x >= 0) == (y >= 0)) { return abs(x)/abs(y); } else { return -((abs(x) + abs(y)-1)/abs(y)); } } template<class T, class U> istream &operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } template<class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; } template <class T> istream &operator>>(istream &is, vector<T> &v) { for(auto &x : v) { is >> x; } return is; } template <class T> ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int)v.size(); i++) { if(i != (int)v.size() - 1) os << v[i] << " "; else os << v[i]; } return os; } template<class T> void print(T A, bool f = true) { cerr << A; if (f) cerr << endl; } template<class T, class U> void print(pair<T, U> A, bool f = true) { cerr << "{" << A.first << ", " << A.second << "}"; if (f) cerr << endl; } template<class T> void print(vector<T> A, bool f = true) { cerr << "{"; for (int i = 0; i<(int)A.size(); i++) { print(A[i], false); if (i+1 != (int)A.size()) cerr << ", "; } cerr << "}"; if (f) cerr << endl; } #define debug(x) cerr << #x << " = "; print(x) #define debug2(x) cerr << #x << " = "; print(x, false) struct IoSetup { IoSetup() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(15); } } iosetup; struct Edge { int to; ll cost; }; const int mod1 = 998244353; const int mod2 = 1000000007; const int inf = 1000010000; const ll INF = 1LL<<60; int main() { int N, M; cin >> N >> M; vector<ll> A(N); rep(i, 0, N) cin >> A[i]; vector<vector<Edge>> G(N); rep(i, 0, M) { int a, b; ll C; cin >> a >> b >> C; a--; b--; G[a].push_back(Edge{b, A[b]-C}); } vector<ll> ans(N, -INF); ans[0] = A[0]; rep(i, 0, N-1) { rep(v, 0, N) { for (Edge e : G[v]) { chmax(ans[e.to], ans[v] + e.cost); } } } vector<bool> f(N, false); rep(i, 0, 2 * N) { rep(v, 0, N) { for (Edge e : G[v]) { if (chmax(ans[e.to], ans[v] + e.cost)) f[e.to] = true; if (f[v]) f[e.to] = true; } } } if (f[N-1]) cout << "inf" << endl; else cout << ans[N-1] << endl; }