Submission #940836

#TimeUsernameProblemLanguageResultExecution timeMemory
940836AndreySemiexpress (JOI17_semiexpress)C++14
100 / 100
134 ms65660 KiB
#include<bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n,m,k,a,b,c,t,sb = 0;
    cin >> n >> m >> k >> a >> b >> c >> t;
    vector<long long> haha(m);
    for(long long i = 0; i < m; i++) {
        cin >> haha[i];
    }
    haha.push_back(n+1);
    long long bruh[m][k+1];
    vector<long long> wow(0);
    for(long long i = 0; i < m; i++) {
        if((haha[i]-1)*b <= t) {
            bruh[i][0] = (t-(haha[i]-1)*b)/a+1;
            bruh[i][0] = min(bruh[i][0],haha[i+1]-haha[i]);
        }
        else {
            bruh[i][0] = 0;
        }
        for(long long j = 1; j <= k; j++) {
            bruh[i][j] = bruh[i][j-1];
            if((haha[i]-1)*b+bruh[i][j-1]*c <= t) {
                bruh[i][j]+=(t-(haha[i]-1)*b-bruh[i][j-1]*c)/a+1;
            }
            bruh[i][j] = min(bruh[i][j],haha[i+1]-haha[i]);
        }
        sb+=bruh[i][0];
        for(long long j = 0; j <= k; j++) {
            bruh[i][j] = min(bruh[i][j],haha[i+1]-haha[i]);
            if(j > 0) {
                wow.push_back(bruh[i][j]-bruh[i][j-1]);
            }
        }
    }
    sort(wow.begin(),wow.end());
    reverse(wow.begin(),wow.end());
    for(long long i = 0; i < k-m; i++) {
        sb+=wow[i];
    }
    cout << sb-1;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...