結果
問題 | No.468 役に立つ競技プログラミング実践編 |
ユーザー |
![]() |
提出日時 | 2019-07-12 03:15:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 324 ms / 2,000 ms |
コード長 | 1,279 bytes |
コンパイル時間 | 1,008 ms |
コンパイル使用メモリ | 102,576 KB |
実行使用メモリ | 21,572 KB |
最終ジャッジ日時 | 2024-11-14 14:07:46 |
合計ジャッジ時間 | 7,201 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 31 |
other | AC * 6 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; int n, m; vector<P> g[100010], gr[100010]; int dp[100010], dp2[100010]; int solve(int x){ if(dp[x]>=0) return dp[x]; int ret=0; for(auto p:g[x]){ ret=max(ret, solve(p.first)+p.second); } return dp[x]=ret; } int solve2(int x){ if(dp2[x]>=0) return dp2[x]; int ret=0; for(auto p:gr[x]){ ret=max(ret, solve2(p.first)+p.second); } return dp2[x]=ret; } int main() { cin>>n>>m; for(int i=0; i<m; i++){ int a, b, c; cin>>a>>b>>c; g[b].push_back({a, c}); gr[a].push_back({b, c}); } fill(dp, dp+n, -1); fill(dp2, dp2+n, -1); for(int i=0; i<n; i++) solve(i); for(int i=0; i<n; i++) solve2(i); int t=dp[n-1]; int p=0; for(int i=0; i<n; i++) if(dp[i]+dp2[i]<t) p++; printf("%d %d/%d\n", t, p, n); return 0; }