#include #include //小数点出力用 //cout << fixed << setprecision(10) << ans; #include #include #include #include #include #include #include using ll = long long; using namespace std; #define modP 998244353 bool chkrng0idx(int pos, int sup) { return (0 <= pos && pos < sup); } int clk4(int num) { return (num - 2) * (num % 2); } void yn(bool tf) { cout << (tf ? "Yes\n" : "No\n"); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int N, M;cin >> N >> M; int P;cin >> P; ll Y;cin >> Y; vector>nxt[200002]; for (int i = 0;i < M;i++) { int A, B, C;cin >> A >> B >> C; nxt[A].push_back({ B,C }); nxt[B].push_back({ A,C }); } ll cost[200002]; for (int i = 2;i <= N;i++)cost[i] = 2e18; bool ok[200002] = { 0 }; priority_queue>Q; Q.push({ 0,1 }); while (!Q.empty()) { int now = Q.top().second; if (ok[now]) { Q.pop(); continue; } ok[now] = 1; cost[now] = Q.top().first * (-1); Q.pop(); for (int j = 0;j < nxt[now].size();j++) { if (ok[nxt[now][j].first])continue; if (cost[nxt[now][j].first] > cost[now] + nxt[now][j].second) { cost[nxt[now][j].first] = cost[now] + nxt[now][j].second; Q.push({ -1 * cost[nxt[now][j].first] ,nxt[now][j].first }); } } } mapMP; for(int i=0;i> D >> E; MP[D] = E; } ll ans = 0; for (int i = 1;i <= N;i++) { if (MP.find(i) == MP.end())continue; ans = max(ans, (Y - cost[i]) / MP[i]); } cout << ans; return 0; }