# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
875987 | ReLice | Semiexpress (JOI17_semiexpress) | C++14 | 0 ms | 348 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 ll long long
#define ld long double
#define pb push_back
#define endl "\n"
#define fr first
#define sc second
#define sz size()
#define ins insert
#define bc back()
#define str string
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);}
void start(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
const ll inf=1e18+7;
const ll mod=1e9;
const ll N=2e5+7;
const ld eps=1e-9;
void solve(){
ll i,j;
ll n,m,k,a,b,c,t,ans=0;
cin>>n>>m>>k>>a>>b>>c>>t;
vector<ll> v(m,0),d(m,0);
for(i=0;i<m;i++){
cin>>v[i];
d[i]=(v[i]-1)*b;
if(d[i]>0 && d[i]<=t)ans++;
}
k-=m;
vector<ll> vv;
for(i=0;i<m-1;i++){
if(d[i]>t)break;
ans+=min((t-d[i])/a,v[i+1]-v[i]-1);
if((t-d[i])/a>=v[i+1]-v[i])continue;
ll x=v[i]+(t-d[i])/a+1,dd;
for(j=0;j<k;j++){
dd=(t-d[i]-(x-v[i])*c);
if(dd<0 || x==v[i+1])break;
vv.pb(min(dd/a+1,v[i+1]-x));
x+=dd/a+1;
}
}
sort(rall(vv));
for(i=0;i<k && i<(ll)vv.sz;i++){
ans+=vv[i];
}cout<<ans<<endl;
}
signed main(){
start();
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ll t=1;
//cin>>t;
while(t--) solve();
}
/*
*/
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... |