Skip to content

Instantly share code, notes, and snippets.

@rogerioagjr
Created February 13, 2017 14:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rogerioagjr/6d512d719f57c05f2d4c6d251f82a41e to your computer and use it in GitHub Desktop.
Save rogerioagjr/6d512d719f57c05f2d4c6d251f82a41e to your computer and use it in GitHub Desktop.
Semiexpress
#include <bits/stdc++.h>
using namespace std;
#define MAXM 3030
typedef long long ll;
ll n, m, k, expr[MAXM];
ll a, b, c, t, resp;
priority_queue<int> heap;
int main(){
cin >> n >> m >> k >> a >> b >> c >> t;
for(int i=0;i<m;i++) cin >> expr[i];
if((n-1)*b<=t) resp++;
for(int i=0;i<m-1;i++){
ll ini=(expr[i]-1)*b;
if(ini>t) break;
ll qtd=(t-ini)/a;
ll range=min(expr[i+1]-1,expr[i]+qtd);
resp+=range-expr[i]+1;
if(i==0) resp--;
for(int j=0;j<k and range<expr[i+1]-1;j++){
ll tempo=ini+(range+1-expr[i])*c;
if(tempo>t) break;
ll q=(t-tempo)/a;
ll new_range=min(expr[i+1]-1,range+1+q);
heap.push(new_range-range);
range=new_range;
}
}
for(int i=m;i<k;i++){
if(heap.empty()) break;
resp+=heap.top();
heap.pop();
}
cout << resp << "\n";
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment