#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=a;i<=(int)b;i++)
#define FORD(i,a,b) for(int i=a;i>=(int)b;i--)
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin(),a.end()
#define BIT(mask,i) ((mask>>(i))&1)
#define MASK(a) (1LL<=((a)))
#define uni(v) sort(all(v)); v.resize(unique(all(v)) - v.begin())
#define pii pair <int, int>
#define vi vector <int>
#define vl vector <ll>
template <class A,class B>
bool maximize(A &a, const B b)
{
if(a < b){a = b; return 1;} return 0;
}
template <class A,class B>
bool minimize(A &a, const B b)
{
if(a > b){a = b; return 1;} return 0;
}
const int maxn = 2e5 + 5;
int n, m, k;
int s[maxn];
int A, B, C;
long long T;
namespace sub1
{
int dp[505][3005], near[505];
bool mark[505];
int cost[505][505];
int pre[3005];
void solve()
{
FOR(i, 1, m) mark[s[i]] = true;
FOR(i, 1, n) near[i] = (mark[i] ? i : near[i - 1]);
FOR(i, 1, n) pre[i] = pre[i - 1] + (mark[i]);
FOR(k, 1, n)
{
FOR(i, k, n)
{
int S = near[k];
FOR(t, k + 1, i - 1)
{
long long costT = 1LL * (S - 1) * B + 1LL * (k - S) * C + 1LL * (t - k) * A;
if(costT <= T) cost[k][i]++;
}
long long costT = 0;
if(mark[i])
costT+= 1LL * (i - 1) * B;
else
costT+= 1LL * (S - 1) * B + 1LL * (k - S) * C + 1LL * (i - k) * C;
if(costT <= T) cost[k][i]++;
}
}
memset(dp, - 0x3f, sizeof dp);
dp[1][1] = 0;
FOR(i, 2, n) FOR(j, 2, k)
{
FOR(k, 1, i - 1)
{
if(pre[i - 1] - pre[k] > 0) continue;
dp[i][j] = max(dp[i][j], dp[k][j - 1] + cost[k][i]);
}
}
cout << dp[n][k];
}
}
void solve()
{
cin >> n >> m >> k >> A >> B >> C >> T;
FOR(i, 1, m)cin>>s[i];
return sub1::solve();
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#define kieuoanh "kieuoanh"
if(fopen(kieuoanh".inp","r"))
{
freopen(kieuoanh".inp","r",stdin);
freopen(kieuoanh".out","w",stdout);
}
int tst = 1;
// cin >> tst;
while(tst--) solve();
return 0;
}
Compilation message (stderr)
semiexpress.cpp: In function 'int main()':
semiexpress.cpp:98:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
98 | freopen(kieuoanh".inp","r",stdin);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
semiexpress.cpp:99:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
99 | freopen(kieuoanh".out","w",stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |