This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |