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>
#define int long long
using namespace std;
int k, n, m, q, x, y, t;
signed main() {
cin >> k >> n >> m >> q;
vector<int> a(n, 1e10), prefix(n);
for(int i = 0; i < m; i++) {
cin >> x >> y >> t;
a[x] = t;
}
for(int i = 0; i < n; i++) prefix[i] = a[i] + (i == 0 ? 0 : prefix[i - 1]);
while(q--) {
cin >> x >> y;
if(prefix[y - 1] - (x == 0 ? 0 : prefix[x - 1]) >= 1e10) cout << "-1\n";
else cout << (prefix[y - 1] - (x == 0 ? 0 : prefix[x - 1])) << "\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... |