# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
557304 | ismoilov | Toll (BOI17_toll) | C++14 | 28 ms | 724 KiB |
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>
using namespace std;
typedef long long ll;
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) (x).begin(), (x).end()
#define fp(a,i,c) for(int (a) = (i); (a) < (c); (a)++)
#define fpp(a,i,c) for(int (a) = (i); (a) <= (c); (a)++)
#define fm(a,i,c) for(int (a) = (i); (a) > (c); (a)--)
#define fmm(a,i,c) for(int (a) = (i); (a) >= (c); (a)--)
const int maxx = 5e4+5;
ll pr[maxx];
void S()
{
int k, n, m, o;
cin >> k >> n >> m >> o;
fpp(i,0,n)
pr[i] = 1e18;
fp(i,0,m){
int a, b, t;
cin >> a >> b >> t;
pr[b] = t;
}
fp(i,0,n)
pr[i+1] += pr[i];
while(o --){
int a, b;
cin >> a >> b;
if(pr[b] - pr[a] >= 1e18 || a >= b)
cout << "-1\n";
else
cout << pr[b] - pr[a] << "\n";
}
}
int main()
{
IOS;
S();
}
Compilation message (stderr)
# | 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... |