#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define replr(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define reprl(i, a, b) for (int i = int(a); i >= int(b); --i)
#define rep(i, n) for (int i = 0; i < int(n); ++i)
#define mkp(a, b) make_pair(a, b)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<PII> VPI;
typedef vector<VI> VVI;
typedef vector<VVI> VVVI;
typedef vector<VPI> VVPI;
typedef pair<ll, ll> PLL;
typedef vector<ll> VL;
typedef vector<PLL> VPL;
typedef vector<VL> VVL;
typedef vector<VVL> VVVL;
typedef vector<VPL> VVPL;
template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;}
template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;}
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T>
using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<bool> VB;
typedef vector<VB> VVB;
void solve() {
ll n, m, k;
cin >> n >> m >> k;
k -= m;
ll A, B, C, T;
cin >> A >> B >> C;
cin >> T;
VL stations(m);
for (ll& x : stations) cin >> x;
vector<tuple<ll, int, int>> vec;
ll start = 0;
replr(i, 1, m-1) {
vec.pb({start, stations[i-1], stations[i]});
start += (stations[i]-stations[i-1]) * B;
}
m--;
VVL step(m);
rep(vecind, m) {
auto[s, l, r] = vec[vecind];
/*cout << "SEGMENT [" << l << ", " << r << ") WITH INITIAL DISTANCE " << s << endl;*/
ll cur = s;
if (cur > T) continue;
replr(i, l+1, r-1) {
cur += A;
if (cur > T) {
cur = s + (i-l) * C;
step[vecind].pb(i-l);
/*cout << "COUNT " << i-l << endl;*/
if (cur > T) break;
}
}
if (cur <= T) {
step[vecind].pb(r-l);
/*cout << "COUNT " << r-l << endl;*/
}
}
rep(i, m) {
reprl(j, step[i].size()-1, 1) {
step[i][j] -= step[i][j-1];
}
}
/*cout << endl << "STEPS" << endl;*/
/*rep(i, m) {*/
/* for (ll x : step[i]) cout << x << " ";*/
/* cout << endl;*/
/*}*/
/*cout << "STEPS" << endl << endl;*/
priority_queue<PLL> pq;
VI pts(m, 0);
int ans = 0;
rep(i, m) {
if (pts[i] != step[i].size()) {
ans += step[i][pts[i]];
pts[i]++;
if (pts[i] != step[i].size()) {
pq.push({-step[i][pts[i]], i});
}
}
}
/*for (int x : pts) cout << x << " "; cout << endl;*/
while (pq.size() && k--) {
auto[_, i] = pq.top();
pq.pop();
if (pts[i] != step[i].size()) {
ans += step[i][pts[i]];
pts[i]++;
if (pts[i] != step[i].size()) {
pq.push({-step[i][pts[i]], i});
}
}
/*for (int x : pts) cout << x << " "; cout << endl;*/
}
if (B * (n-1) <= T) ans++;
cout << ans-1 << endl;
/*VVPL trans(n+1);*/
/*replr(i, 2, n) trans[i].pb({i-1, A});*/
/*replr(i, 1, m-1) {*/
/* ll u = stations[i-1];*/
/* ll v = stations[i];*/
/* trans[v].pb({u, (v-u)*B});*/
/*}*/
/*VL dist(n+1, 1e18);*/
/*dist[1] = 0;*/
/*replr(v, 2, n) {*/
/* for (auto[u, w] : trans[v]) {*/
/* setmin(dist[v], dist[u] + w);*/
/* }*/
/*}*/
/*ll ans = n-1;*/
/*replr(i, 1, n) if (dist[i] > T) ans--;*/
/*cout << ans << endl;*/
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL), cout.tie(NULL);
/*freopen("mincross.in", "r", stdin); */
/*freopen("test.out", "w", stdout); */
int t = 1;
/*cin >> t; */
while (t--) solve();
}
Compilation message
semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:55:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
55 | auto[s, l, r] = vec[vecind];
| ^
semiexpress.cpp:89:20: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
89 | if (pts[i] != step[i].size()) {
semiexpress.cpp:92:24: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
92 | if (pts[i] != step[i].size()) {
semiexpress.cpp:101:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
101 | auto[_, i] = pq.top();
| ^
semiexpress.cpp:103:20: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
103 | if (pts[i] != step[i].size()) {
semiexpress.cpp:106:24: warning: comparison of integer expressions of different signedness: '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
106 | if (pts[i] != step[i].size()) {
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
0 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
0 ms |
348 KB |
Output is correct |
14 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |