# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1110227 | vjudge1 | Tower (JOI24_tower) | C++17 | 63 ms | 20552 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;
int n,q;
long long d,a,b;
long long f[2000000];
int k[2000000];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
if(fopen("c.INP","r")){
freopen("c.INP","r",stdin);
freopen("c.OUT","w",stdout);
}
cin >>n>>q;
cin >>d>>a>>b;
while(n--){
int l,r;
cin >>l>>r;
k[l]++;
k[r+1]--;
}
for(int i=1;i<=1000000;i++){
k[i]+=k[i-1];
if(k[i])f[i]=1e17;
else{
if(i>=d)f[i]=min(f[i-1]+a,f[i-d]+b);
else f[i]=f[i-1]+a;
}
}
while(q--){
int x;
cin >>x;
if(f[x]<1e17)cout <<f[x]<<'\n';
else cout <<-1<<'\n';
}
}
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... |