Submission #1051740

# Submission time Handle Problem Language Result Execution time Memory
1051740 2024-08-10T09:24:23 Z c2zi6 Semiexpress (JOI17_semiexpress) C++14
18 / 100
0 ms 348 KB
#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;*/
    }

    /*int ans = 0;*/
    while (pq.size()) {
        auto[s, l, r] = pq.top();
        s *= -1;
        pq.pop();
        ll m = l + (T - s) / A + 1;

        /*cout << "PROCESSING SEGMENT [" << l << ", " << r << ") WITH STARTING DISTANCE " << s << endl;*/
        /*cout << "MAKING AN EDGE (" << l << ", " << m << ") WITH WEIGHT " << (m-l)*C << endl;*/

        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

semiexpress.cpp: In function 'void solve()':
semiexpress.cpp:68:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   68 |         auto[s, l, r] = pq.top();
      |             ^
semiexpress.cpp:98:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   98 |     for (auto[s, l, r] : vat) {
      |              ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 344 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 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 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 Correct 0 ms 348 KB Output is correct
15 Incorrect 0 ms 348 KB Output isn't correct
16 Halted 0 ms 0 KB -