Submission #669154

# Submission time Handle Problem Language Result Execution time Memory
669154 2022-12-05T20:43:58 Z Dec0Dedd Semiexpress (JOI17_semiexpress) C++14
100 / 100
1 ms 340 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define pp pair<ll, pii>

const int M = 3e3+1;

ll s[M], n, m, k, a, b, c, t;

int main() {
    cin>>n>>m>>k; k-=m;
    cin>>a>>b>>c>>t;
    for (int i=1; i<=m; ++i) cin>>s[i];

    priority_queue<pp> pq;
    ll ans=-1;

    for (int i=1; i<m; ++i) {
        ll tmp=b*(s[i]-1), x=(t-tmp)/a;
        if (b*(s[i]-1) > t) continue;
        if (s[i]+x >= s[i+1]) x=s[i+1]-s[i]-1;
        ans+=x+1;

        ll nxt=s[i]+x+1, sz=s[i+1]-nxt;
        ll cost=b*(s[i]-1)+(nxt-s[i])*c;
        if (cost > t) continue;
        ll h=(t-cost)/a+1;

        if (min(sz, h) <= 0) continue;
        pq.push({min(sz, h), {i, nxt}});
    }

    while (k-- && !pq.empty()) {
        pp g=pq.top(); pq.pop();
        ans+=g.first;
        ll nxt=g.second.second+g.first, i=g.second.first;
        ll cost=b*(s[i]-1)+(nxt-s[i])*c, sz=s[i+1]-nxt;
        if (cost > t) continue;
        ll h=(t-cost)/a+1;

        if (min(sz, h) <= 0) continue;
        pq.push({min(sz, h), {i, nxt}});
    }

    if (b*(s[m]-1) <= t) ++ans;
    cout<<ans<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 308 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 304 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 1 ms 212 KB Output is correct
16 Correct 0 ms 212 KB Output is correct
17 Correct 0 ms 212 KB Output is correct
18 Correct 1 ms 304 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 312 KB Output is correct
22 Correct 1 ms 212 KB Output is correct
23 Correct 1 ms 328 KB Output is correct
24 Correct 1 ms 312 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 312 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct