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;
#define int long long
const int INF = 1e18+1;
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,q,d,A,B;
cin >> n >> q >> d >> A >> B;
vector<int> DP(1e6+1);
for(int i=1;i<=n;i++){
int l,r;cin>>l>>r;
for(int j=l;j<=r;j++)DP[j]=INF;
}
for(int i=1;i<=1e6;i++){
if(i<d)DP[i]=max(DP[i],DP[i-1]+A);
else DP[i]=max(DP[i],min(DP[i-1]+A,DP[i-d]+B));
}
for(int i=1;i<=q;i++){
int x;cin>>x;
cout << (DP[x]>=INF ? -1 : DP[x]) << '\n';
}
}
# | 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... |