This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> trio;
typedef pair<int,int> pii;
const int MAXN = 2e5+5;
const ll INF = 1e9;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
int n, m, k, v[3005], ans;
ll t, A, B, C;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k >> A >> B >> C >> t;
    k -= m;
    for(int i = 1; i <= m; i++)
        cin >> v[i];
    vector<int> val;
    v[m+1] = n+1;
    for(int i = 1; i <= m; i++) {
        ll tempo = (v[i] - 1) * B;
        if(tempo > t) break;
        int qtd = (t - tempo)/A;
        qtd = min(qtd, v[i+1] - v[i] - 1);
        ans += qtd+1;
        for(int j = 1, at = qtd + v[i] + 1; j <= k and at < v[i+1]; j++) {
            tempo = (v[i] - 1) * B + (at - v[i]) * C;
            if(tempo > t) break;
            qtd = (t - tempo)/A;
            qtd = min(qtd,  v[i+1] - at - 1);
            val.pb(qtd + 1);
            at += qtd + 1;
        }
    }
    sort(all(val));
    reverse(all(val));
    for(int i = 0; i < min(k, sz(val)); i++) ans += val[i];
    cout << ans-1 << "\n";
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |