# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938766 |
2024-03-05T14:10:27 Z |
vjudge1 |
Toll (BOI17_toll) |
C++17 |
|
18 ms |
1116 KB |
#include <bits/stdc++.h>
#include <random>
#define int long long
using namespace std;
const int inf = 1e9;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int k,n,m,o;
cin >> k >> n >> m >> o;
vector<int> edges(n-1,inf);
for (int i = 0; i < m; i++)
{
int a,b,c;
cin >> a >> b >> c;
edges[a] = min(c,edges[a]);
}
vector<int> pref_sum(n-1,0);
pref_sum[0] = edges[0];
for (int i = 1; i < n-1; i++)
pref_sum[i] = pref_sum[i-1]+edges[i];
auto sum = [&](int l,int r)
{
return pref_sum[r] - (l > 0 ? pref_sum[l-1] : 0LL);
};
for (int i = 0; i < o; i++)
{
int a,b;
cin >> a >> b;
if (sum(a,b-1) >= inf)
cout << -1 << '\n';
else
cout << sum(a,b-1);
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
18 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
1116 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |