#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define st first
#define nd second
typedef long long ll;
typedef long double ld;
const ll I = 1'000'000'000'000'000'000LL;
const int II = 2'000'000'000;
const ll M = 1'000'000'007LL;
const int N = 1'000'007;
int tab[N], cur[N];
ll A, B, C, T;
int answer = 0;
priority_queue<pair<int, int>> q;
int Dod(int i, int l, int r)
{
ll nd = (ll)(l - 1) * B + (ll)(i - l) * C;
if(nd > T) return 0;
int a = min((T - nd) / A + 1LL, (ll)(r - i));
return a;
}
void Solve()
{
int n, m, k;
cin >> n >> m >> k;
cin >> A >> B >> C;
cin >> T;
for(int i = 1; i <= m; ++i)
{
cin >> tab[i];
cur[i] = tab[i];
}
for(int i = 1; i < m; ++i)
{
int a = Dod(tab[i], tab[i], tab[i + 1]);
answer += a;
cur[i] = tab[i] + a;
a = Dod(cur[i], tab[i], tab[i + 1]);
if(a != 0)
q.push(make_pair(a, i));
}
if((ll)(n - 1) * B <= T) ++answer;
int cnt = k - m;
while(cnt-- && (int)q.size() > 0)
{
int i = q.top().nd; answer += q.top().st;
cur[i] += q.top().st;
q.pop();
int a = Dod(cur[i], tab[i], tab[i + 1]);
if(a != 0)
q.push(make_pair(a, i));
}
cout << answer - 1 << "\n";
}
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
//int t; cin >> t;
//while(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... |