Submission #472369

#TimeUsernameProblemLanguageResultExecution timeMemory
472369elgamalsalmanToll (BOI17_toll)C++14
7 / 100
56 ms5128 KiB
#include <bits/stdc++.h> using namespace std; #define fi first #define se second typedef long long ll; typedef pair<ll, ll> ii; typedef vector<ll> vi; typedef vector<ii> vii; typedef vector<vii> vvii; ll k, n, m, o, pSum[50050]; vvii adj; int main() { ios_base::sync_with_stdio(0); cin.tie(0); fill(pSum, pSum + 50050, -1e10); cin >> k >> n >> m >> o; adj.assign(n + 20, vii()); for (ll i = 0; i < m; i++) { ll a, b, t; cin >> a >> b >> t; adj[a].push_back({b, t}); pSum[b] = t; } for (int i = 1; i < 50050; i++) pSum[i] += pSum[i - 1]; for (ll i = 0; i < o; i++) { ll a, b; cin >> a >> b; ll toll = pSum[b] - pSum[a]; cout << (toll < 0 ? -1 : toll) << '\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...