#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
const ll inf=1ll<<60;
#define exp asdf
int n, m, k;
ll a, b, c;
ll T;
vector<int> exp;
void in(){
//freopen("in", "r", stdin);
read(n, m, k, a, b, c, T);
for(int i=1; i<=m; ++i){
int x; read(x); exp.pb(x);
}
}
ll gs[3010];
ll gl[3010];
ll lst[3010];
priority_queue<pair<ll,int>> pq;
ll getearn(ll gs, ll gl, ll p){
if(gs-c*p < 0) return -1;
ll r=p+(gs-c*p)/a;
r=min(r, gl-1);
return r-p+1;
}
void build(){
sort(all(exp));
for(int i=0; i<m-1; ++i){
gs[i]=T-(exp[i]-1)*b;
gl[i]=exp[i+1]-exp[i];
lst[i]=min(gl[i]-1, gs[i]/a);
if(lst[i]+1 <= gl[i]-1){
ll earn=getearn(gs[i], gl[i], lst[i]+1);
if(earn > 0){
pq.push(make_pair(earn, i));
lst[i] = min(gl[i]-1, lst[i]+earn);
}
}
}
}
int main()
{
in();
build();
int ans=0;
for(int i=0; i<m-1; ++i){
int l=exp[i], r=exp[i+1];
if(T-(l-1)*b < 0) break;
ll t=(T-(l-1)*b)/a;
t=min(t, ll(r-l-1));
ans += t+1;
}
if((n-1)*b <= T) ans++;
for(int I=0; I<k-m && pq.size(); ++I){
ans += pq.top().first;
int i=pq.top().second;
pq.pop();
if(lst[i]+1 <= gl[i]-1){
ll earn=getearn(gs[i], gl[i], lst[i]+1);
if(earn > 0){
pq.push(make_pair(earn, i));
lst[i] = min(gl[i]-1, lst[i]+earn);
}
}
}
printf("%d\n", ans-1);
return 0;
}
Compilation message
semiexpress.cpp: In function 'void read(int&)':
semiexpress.cpp:5:25: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
5 | void read(int& x){ scanf("%d",&x); }
| ~~~~~^~~~~~~~~
semiexpress.cpp: In function 'void read(ll&)':
semiexpress.cpp:6:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
6 | void read(ll& x){ scanf("%lld",&x); }
| ~~~~~^~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
360 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
360 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
360 KB |
Output is correct |
7 |
Correct |
0 ms |
256 KB |
Output is correct |
8 |
Correct |
1 ms |
384 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
256 KB |
Output is correct |
11 |
Correct |
1 ms |
384 KB |
Output is correct |
12 |
Correct |
1 ms |
384 KB |
Output is correct |
13 |
Correct |
1 ms |
256 KB |
Output is correct |
14 |
Correct |
1 ms |
384 KB |
Output is correct |
15 |
Correct |
1 ms |
384 KB |
Output is correct |
16 |
Correct |
0 ms |
384 KB |
Output is correct |
17 |
Correct |
1 ms |
256 KB |
Output is correct |
18 |
Correct |
0 ms |
256 KB |
Output is correct |
19 |
Correct |
1 ms |
384 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
1 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
384 KB |
Output is correct |
25 |
Correct |
1 ms |
384 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
1 ms |
384 KB |
Output is correct |
29 |
Correct |
1 ms |
384 KB |
Output is correct |
30 |
Correct |
1 ms |
416 KB |
Output is correct |