# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1161996 | guagua0407 | Tower (JOI24_tower) | C++20 | 47 ms | 13128 KiB |
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};
void setIO(string s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
const ll inf=(ll)1e18;
int main() {_
int n,q;
cin>>n>>q;
ll d,a,b;
cin>>d>>a>>b;
vector<ll> L(n+1),R(n+1);
L[0]=-1;
R[0]=-1;
for(int i=1;i<=n;i++){
cin>>L[i]>>R[i];
}
vector<pair<ll,ll>> no;
auto in=[&](ll x){
int pos=lower_bound(all(R),x)-R.begin();
if(pos<=n and L[pos]<=x) return true;
return false;
};
auto in2=[&](ll x){
int pos=upper_bound(all(no),make_pair(x,inf))-no.begin();
if(pos>0 and x<=no[pos-1].s) return true;
return false;
};
bool one=false;
if(true or (a*d)<=b) one=true;
auto solve1=[&](){
int mxn=1e6+5;
vector<ll> dp(mxn);
for(int i=1;i<=n;i++){
for(int j=L[i];j<=R[i];j++){
dp[j]=inf;
}
}
for(int i=1;i<mxn;i++){
if(dp[i]==inf) continue;
dp[i]=dp[i-1]+a;
if(i>=d) dp[i]=min(dp[i],dp[i-d]+b);
}
for(int i=0;i<q;i++){
ll x;
cin>>x;
if(dp[x]>=inf) cout<<-1<<'\n';
else cout<<dp[x]<<'\n';
}
};
auto solve2=[&](){
};
if(one) solve1();
else solve2();
return 0;
}
//maybe its multiset not set
//yeeorz
//diaoborz
/*
3 1
4 1 4
4 5
10 12
14 14
13
5 10
10 1 10
7 11
25 32
37 38
43 44
50 52
6
12
18
24
30
36
42
48
54
60
*/
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... |