제출 #1128073

#제출 시각아이디문제언어결과실행 시간메모리
1128073stdfloatToll (BOI17_toll)C++20
100 / 100
2059 ms4616 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int k, n, m, q; cin >> k >> n >> m >> q; vector<pair<int, int>> E[n]; while (m--) { int x, y, w; cin >> x >> y >> w; E[y].push_back({x, w}); } while (q--) { int x, y; cin >> x >> y; if (x > y) { cout << "-1\n"; continue; } vector<int> dp(n, (int)2e9); dp[x] = 0; for (int i = x + 1; i <= y; i++) { for (auto [j, w] : E[i]) dp[i] = min(dp[i], dp[j] + w); } cout << (dp[y] == (int)2e9 ? -1 : dp[y]) << '\n'; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...