#include using namespace std; using pii = pair; #define rep(i, j) for(int i=0; i < (int)(j); i++) template bool set_min(T &a, const T &b) { return a > b ? a = b, true : false; } template bool set_max(T &a, const T &b) { return a < b ? a = b, true : false; } // vector template istream& operator >> (istream &is , vector &v) { for(T &a : v) is >> a; return is; } template ostream& operator << (ostream &os , const vector &v) { for(const T &t : v) os << "\t" << t; return os << endl; } // pair template ostream& operator << (ostream &os , const pair &v) { return os << "<" << v.first << ", " << v.second << ">"; } const int INF = 1 << 30; class Solver { public: int N, M; vector> E; vector> RE; vector earliest, latest; int calc_earliest(int now) { if(earliest[now] >= 0) return earliest[now]; int res = 0; for(auto e : RE[now]) { set_max(res, calc_earliest(e.first) + e.second); } return earliest[now] = res; } int calc_latest(int now) { if(latest[now] < INF) return latest[now]; int res = earliest[N - 1]; for(auto e: E[now]) { set_min(res, calc_latest(e.first) - e.second); } return latest[now] = res; } set calc_critical_path(const vector &earliest, const vector &latest) { set ret; queue que; que.push(N - 1); while(que.size()) { int now = que.front(); que.pop(); if(ret.count(now)) continue; ret.insert(now); for(auto e : RE[now]) { if(earliest[e.first] == latest[e.first]) { if(not ret.count(e.first)) { que.push(e.first); } } } } return ret; } bool solve() { cin >> N >> M; E.resize(N); RE.resize(N); rep(i, M) { int a, b, c; cin >> a >> b >> c; E[a].push_back(make_pair(b, c)); RE[b].push_back(make_pair(a, c)); } earliest.resize(N, -1); latest.resize(N, INF); calc_earliest(N - 1); calc_latest(0); //cerr << earliest << endl; //cerr << latest << endl; //cerr << calc_critical_path(earliest, latest) << endl; int T = earliest[N - 1]; int P = N - calc_critical_path(earliest, latest).size(); cout << T << " " << P << "/" << N << endl; return 0; } }; int main() { cin.tie(0); ios::sync_with_stdio(false); Solver s; s.solve(); return 0; }