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 ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
int main(){
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
ll n,m,k;
cin>>n>>m>>k;
ll a,b,c;
cin>>a>>b>>c;
ll t;
cin>>t;
ll s[m+5];
vector<bool>used(n+5,0);
for(ll i=1;i<=m;i++){
cin>>s[i];
used[s[i]]=true;
}
vector<ll>v;
for(ll i=1;i<=n;i++){
if(!used[i]){
v.pb(i);
}
}
vector<pair<ll,ll>>bef[n+5];
for(ll i=2;i<=n;i++){
bef[i].pb({i-1,0});
}
for(ll i=1;i<m;i++){
bef[s[i+1]].pb({s[i],1});
}
ll dp[n+5],ans=0;
for(ll i=0;i<v.size();i++){
for(ll j=i+1;j<v.size();j++){
ll last=0;
for(ll l=1;l<=n;l++){
if(used[l]||l==v[i]||l==v[j]){
if(last>0) bef[l].pb({last,2});
last=l;
}
}
dp[1]=0;
ll cur=0;
for(ll l=2;l<=n;l++){
dp[l]=1e18;
for(auto [x,y]:bef[l]){
if(y==0) dp[l]=min(dp[l],dp[x]+(l-x)*a);
if(y==1) dp[l]=min(dp[l],dp[x]+(l-x)*b);
if(y==2) dp[l]=min(dp[l],dp[x]+(l-x)*c);
}
if(dp[l]<=t){
cur++;
}
}
ans=max(ans,cur);
last=0;
for(ll l=1;l<=n;l++){
if(used[l]||l==v[i]||l==v[j]){
if(last>0) bef[l].pop_back();
last=l;
}
}
}
}
cout<<ans;
}
Compilation message (stderr)
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:40:17: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | for(ll i=0;i<v.size();i++){
| ~^~~~~~~~~
semiexpress.cpp:41:23: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | for(ll j=i+1;j<v.size();j++){
| ~^~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |