# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1167794 | hainam2k9 | Semiexpress (JOI17_semiexpress) | C++20 | 0 ms | 336 KiB |
#include <bits/stdc++.h>
#define tt cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(0)
#define fo freopen((NAME+".INP").c_str(), "r", stdin), freopen((NAME+".OUT").c_str(), "w", stdout)
#define ll long long
#define ull unsigned long long
#define i128 __int128
#define db long double
#define sz(a) ((int)(a).size())
#define pb emplace_back
#define pf emplace_front
#define pob pop_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define ins emplace
#define mp make_pair
using namespace std;
const int MOD = 1e9+7, MAXN = 1e5+5;
const string NAME = "";
int n,m,k,rs=0,a[3005];
ll cost[3],t;
priority_queue<pair<int,pair<ll,int>>> pq;
int main()
{
tt;
if(fopen((NAME + ".INP").c_str(), "r")) fo;
cin >> n >> m >> k;
for(int i = 0; i<3; ++i)
cin >> cost[i];
cin >> t;
for(int i = 1; i<=m; ++i){
cin >> a[i];
rs+=cost[1]*(a[i]-1)<=t;
}
k-=m;
for(int i = 1; i<m; ++i){
ll used=cost[1]*(a[i]-1);
if(used>t||a[i+1]-a[i]-1==0) continue;
int can=min(1ll*a[i+1]-a[i]-1,(t-used)/cost[0]);
rs+=can, used+=(can+1)*cost[2];
if(used<=t&&a[i+1]-a[i]-1-can>0){
int can2=min(1ll*a[i+1]-a[i]-1-can,(t-used)/cost[0]+1);
pq.ins(can2,mp(used,a[i+1]-a[i]-1-can-can2));
}
}
while(k>0&&!pq.empty()){
pair<int,pair<ll,int>> p=pq.top();
rs+=p.fi, --k, pq.pop();
ll used=p.se.fi+p.fi*cost[2];
if(used<=t&&p.se.se>0){
int can=min(1ll*p.se.se,(t-used)/cost[0]+1);
pq.ins(can,mp(used,p.se.se-can));
}
}
cout << rs-1;
}
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... |