# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1040806 |
2024-08-01T09:47:22 Z |
n3rm1n |
Toll (BOI17_toll) |
C++17 |
|
12 ms |
3672 KB |
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN = 5e4 + 10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}
struct querie
{
ll ql, qr, index;
querie(){};
querie(ll _ql, ll _qr, ll _index)
{
ql = _ql;
qr = _qr;
index = _index;
}
};
ll k, n, m, q;
vector < pair < ll, ll > > g[MAXN];
int a[MAXN], is[MAXN];
ll prefa[MAXN], cnt[MAXN];
void read()
{
cin >> k >> n >> m >> q;
ll from, to, cost;
for (ll i = 1; i <= m; ++ i)
{
cin >> from >> to >> cost;
from ++;
to ++;
is[from] = 1;
a[from] = cost;
}
for (int i = 1; i <= n; ++ i)
{
prefa[i] = prefa[i-1] + a[i];
cnt[i] = cnt[i-1] + is[i];
}
while(q --)
{
int ql, qr;
cin >> ql >> qr;
ql ++;
qr ++;
int curr_cnt = cnt[qr-1] - cnt[ql-1];
if(curr_cnt != qr - ql)cout << -1 << endl;
else cout << prefa[qr-1] - prefa[ql - 1] << endl;
}
}
void queries()
{
ll ql, qr;
for (ll i = 1; i <= q; ++ i)
{
cin >> ql >> qr;
}
}
int main()
{
speed();
read();
// queries();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
9 ms |
3508 KB |
Output is correct |
9 |
Correct |
9 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2908 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
2652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
1 ms |
2484 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
2652 KB |
Output is correct |
2 |
Correct |
1 ms |
2396 KB |
Output is correct |
3 |
Correct |
1 ms |
2392 KB |
Output is correct |
4 |
Correct |
0 ms |
2396 KB |
Output is correct |
5 |
Correct |
1 ms |
2652 KB |
Output is correct |
6 |
Correct |
1 ms |
2652 KB |
Output is correct |
7 |
Correct |
1 ms |
2652 KB |
Output is correct |
8 |
Correct |
9 ms |
3508 KB |
Output is correct |
9 |
Correct |
9 ms |
3672 KB |
Output is correct |
10 |
Correct |
2 ms |
2908 KB |
Output is correct |
11 |
Incorrect |
12 ms |
2652 KB |
Output isn't correct |
12 |
Halted |
0 ms |
0 KB |
- |