#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <string>
#include <cstring>
#include <iterator>
#include <random>
#define ll long long
#define ld long double
#define inf (ll)(2*1e18)
//#define sort(a) sort(a.begin(), a.end())
#define reverse(a) reverse(a.begin(), a.end())
#define pb push_back
#define endl "\n"
using namespace std;
void solve(){
ll n, m, k, A, B, C, t, i, x, y, z, w, ans, cnt;
cin>>n>>m>>k>>A>>B>>C>>t;
vector<ll> a(m);
vector<ll> b(m-1);
map<ll, vector<pair<ll, ll>>> s;
for(i=0;i<m;++i){
cin>>a[i];
}
ans = -1;
for(i=0;i<m-1;++i){
b[i] = a[i+1] - a[i] - 1;
cnt = t - B*(a[i]-1);
if(cnt < 0) break;
++ans;
x = cnt/A;
if(x >= b[i]){
ans += b[i];
}else{
ans += x;
++x;
cnt -= x*C;
if(cnt < 0) continue;
y = cnt/A;
y = min(b[i] - x, y) + 1;
if(y > 0) s[y].pb({x + y, i});
}
}
if((a[m-1]-1)*B <= t) ++ans;
for(i=m;i<k;++i){
if(s.empty()) break;
x = s.rbegin()->second.back().first;
y = s.rbegin()->second.back().second;
s.rbegin()->second.pop_back();
ans += s.rbegin()->first;
if(s.rbegin()->second.empty()) s.erase(s.rbegin()->first);
cnt = t - (a[y]-1)*B - x*C;
if(cnt < 0) continue;
w = cnt/A;
w = min(b[y] - x, w) + 1;
if(w > 0) s[w].pb({x + w, y});
}
cout<<ans<<endl;
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
srand(time(nullptr));
ll t=1;
// cin>>t;
for(;t>0;--t){
solve();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |