This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
priority_queue<tuple<ll, ll, ll>> pq;
ll start = 0;
replr(i, 1, m-1) {
pq.push({-start, stations[i-1], stations[i]});
start += (stations[i]-stations[i-1]) * B;
}
vector<tuple<ll, ll, ll>> vat;
VVPL trans(n+1);
replr(i, 2, n) {
trans[i].pb({i-1, A});
/*cout << i-1 << " " << i << " " << A << endl;*/
}
replr(i, 1, m-1) {
ll u = stations[i-1];
ll v = stations[i];
trans[v].pb({u, (v-u)*B});
/*cout << u << " " << v << " " << (v-u)*B << endl;*/
}
while (pq.size()) {
auto[s, l, r] = pq.top();
s *= -1;
pq.pop();
ll m = l + (T - s) / A + 1;
if (k == 0 || s > T || m >= r) {
vat.pb({s, l, r});
continue;
}
/*cout << "PROCESSING SEGMENT [" << l << ", " << r << ") WITH STARTING DISTANCE " << s << endl;*/
/*cout << "MAKING AN EDGE (" << l << ", " << m << ") WITH WEIGHT " << (m-l)*C << endl;*/
trans[m].pb({l, (m-l)*C});
pq.push({-(s + (m-l)*C), m, r});
k--;
}
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 ans = n-1;*/
/*for (auto[s, l, r] : vat) {*/
/* cout << "STARTING AT DISTANCE " << s << ", SEGMENT [" << l << ", " << r << ")" << endl;*/
/* replr(i, l, r-1) {*/
/* if (s > T) {*/
/* cout << "DISTANCE " << s << " > " << T << endl;*/
/* ans--;*/
/* }*/
/* s += A;*/
/* }*/
/*}*/
/*if (B * (n-1) > 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 (stderr)
semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:67:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
67 | auto[s, l, r] = pq.top();
| ^
semiexpress.cpp:85:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
85 | for (auto[u, w] : trans[v]) {
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |