結果
| 問題 |
No.3013 ハチマキ買い星人
|
| コンテスト | |
| ユーザー |
SyNtAx_error_1
|
| 提出日時 | 2025-02-22 03:11:29 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,197 bytes |
| コンパイル時間 | 3,319 ms |
| コンパイル使用メモリ | 298,256 KB |
| 実行使用メモリ | 229,996 KB |
| 最終ジャッジ日時 | 2025-02-22 03:11:39 |
| 合計ジャッジ時間 | 8,948 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 1 WA * 3 TLE * 1 -- * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using T = tuple<ll, ll, int>;
ll Y;
bool operator<(T& t1, T& t2) {
return (Y - get<0>(t1)) * get<1>(t2) < (Y - get<0>(t2)) * get<1>(t1);
}
int main() {
int N, M, P;
cin >> N >> M >> P >> Y;
vector<vector<pair<int, ll>>> G(N);
for (int i = 0; i < M; i++) {
int a, b, c;
cin >> a >> b >> c;
a--, b--;
G[a].push_back({b, c});
G[b].push_back({a, c});
}
map<int, ll> mp;
for (int i = 0; i < P; i++) {
ll d, e;
cin >> d >> e;
mp[d - 1] = e;
}
// (cost, e, to)を乗せる
// cost/eの最大化
// (Y-cost1)*e2<(Y-cost2)*e1
ll ans{};
priority_queue<T> que;
if (!mp.contains(0))
que.push({0, 1000000000, 0});
else
que.push({0, mp[0], 0});
vector<ll> dist(N);
while (!que.empty()) {
auto [c, e, now] = que.top();
que.pop();
ans = max(ans, (Y - c) / e);
if (dist[now] > (Y - c) / e) continue;
for (auto&& [p, c2] : G[now]) {
if (c + c2 > Y) continue;
auto e2 = e;
if (mp.contains(p)) e2 = mp[p];
T t2{c + c2, e2, p};
if (dist[p] >= (c + c2) / e2) continue;
que.push({t2});
}
}
cout << ans << endl;
}
SyNtAx_error_1