# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
441676 |
2021-07-05T18:49:39 Z |
Mahfel |
Toll (BOI17_toll) |
C++17 |
|
103 ms |
3088 KB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MXN = 5e4 + 20;
ll a[MXN] , pref[MXN] , block[MXN];
int main() {
ll k,n,m,o;
cin >> k >> n >> m >> o;
for(int i = 0 ; i < m ; i++) {
int v,u,t; cin >> v >> u >> t;
a[u] = t;
}
block[0] = 1;
for(int i = 1 ; i < n ; i++) {
pref[i] = (a[i] == 0 ? 0 : a[i]+pref[i-1]);
block[i] = (a[i] == 0 ? block[i-1]+1 : block[i-1]);
}
while(o--) {
int v,u; cin >> v >> u;
if(block[v] != block[u] || u < v) {
cout << "-1\n"; continue;
}
cout << pref[u]-(pref[v] == 0 ? 0 : pref[v-1]) << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
2372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
103 ms |
3088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
67 ms |
2372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |