Submission #1265384

#TimeUsernameProblemLanguageResultExecution timeMemory
1265384XXBabaProBerkaySemiexpress (JOI17_semiexpress)C++20
100 / 100
11 ms4544 KiB
// Bu zor bir problem DEGIL!!!
#include <bits/stdc++.h>
using namespace std;

#define F first
#define S second
#define PB push_back
#define MP make_pair

using ll = long long;
using pi = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
using vec = vector<T>;

const ll INF = 1e15 + 7;
const int MOD = 998244353;

void solve()
{
	ll N, M, K;
	cin >> N >> M >> K;
	vec<ll> S(M + 1);
	ll A, B, C, T;
	cin >> A >> B >> C >> T;
	for (int i = 1; i <= M; i++)
		cin >> S[i];

	K -= M;
	ll ans = 0;
	vec<ll> v;
	for (int i = 1; i < M; i++)
	{
		ll p = S[i];
		ll cnt = 0;
		while (p < S[i + 1])
		{
			ll t = T - B * (S[i] - 1) - C * (p - S[i]);
			if (t < 0) break;
			ll loc = t / A + 1;
			if (p + loc >= S[i + 1])
				loc = S[i + 1] - p;
			if (p == S[i]) ans += loc;
			else {
				v.PB(loc);
				cnt++;
			}
			p += loc;
			if (cnt >= K) break;
		}
	}

	ans += (B * (N - 1) <= T);

	sort(v.begin(), v.end(), greater<ll>());
	for (int i = 0; i < min((ll)v.size(), K); i++)
		ans += v[i];

	cout << ans - 1 << '\n';
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t = 1;
	//cin >> t;
	while (t--) solve();
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...