# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
938753 | vjudge1 | Toll (BOI17_toll) | C++17 | 0 ms | 0 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>
#define int long long
#define endl "\n"
using namespace std;
vector<int>tree;
signed main(){
int k,n,m,o;
cin>>k>>n>>m>>o;
for(int i=0;i<n;i++)tree.push_back(-1);
for(int i=0;i<m;i++){
int a,b,t;
cin>>a>>b>>t;
tree[a]=t;
}
for(int i=0;i<o;i++){
int a,b;
cin>>a>>b;
int sum=0;
bool flag=false;
for(int j=a;j<b;j++){
if(tree[j]==-1){
flag=true;
}else{
sum+=tree[j];
}
}
if(flag==true){
cout<<-1<<endl
}else{
cout<<sum<<endl;
}
}
}