Submission #938793

#TimeUsernameProblemLanguageResultExecution timeMemory
938793vjudge1Toll (BOI17_toll)C++17
7 / 100
70 ms1500 KiB
#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 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...