#include #include #include #include using namespace std; using i64 = long long; struct edge { int to; i64 cost; }; vector> G0, rG; vector cost0, rcost; int main(void) { int n, m; scanf("%d%d", &n, &m); G0.assign(n, vector()); rG.assign(n, vector()); int a, b; i64 c; for(int i=0; i que; que.push(0); while(!que.empty()) { int v = que.front(); que.pop(); for(edge e : G0[v]) { if(cost0[e.to] < cost0[v] + e.cost) { cost0[e.to] = cost0[v] + e.cost; que.push(e.to); } } } rcost.assign(n, 0); que.push(n-1); while(!que.empty()) { int v = que.front(); que.pop(); for(edge e : rG[v]) { if(rcost[e.to] < rcost[v] + e.cost) { rcost[e.to] = rcost[v] + e.cost; que.push(e.to); } } } int days = cost0[n-1]; for(int i=0; i