#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
typedef long long i64;
using namespace std;
const int N = 5e3 + 5;
int dp [N][N][2][2];
int k, n, m, a, b;
int felicidade_evento [N];
int dia_evento [N];
int tarefas [N];
int solve (int p, int task, bool skip_task, bool skip_day) {
if (task >= m) {
return 0;
}
if (p >= n) {
if (skip_task == false) {
return ( a + (m - task) * b);
} else {
return ( (m - task) * b );
}
}
int &res = dp[p][task][skip_task][skip_day];
if (~res) return res;
res = -1e9;
if (tarefas[task] == dia_evento[p]) {
res = max (res, felicidade_evento[tarefas[task]] + solve (p + 1, task + 1, false, false));
} else {
if (skip_task == false) {
res = max (res, a + b + solve (p, task + 1, true, skip_day));
}
if (skip_task == true){
res = max (res, b + solve (p, task + 1, true, skip_day));
}
if (skip_day == false) {
res = max (res, a + b + solve (p + 1, task, skip_task, true));
}
if (skip_day == true) {
res = max (res, b + solve (p + 1, task, skip_task, true));
}
}
return res;
}
int main () {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> k >> n >> m >> a >> b;
for (int i = 1; i <= k; i++) cin >> felicidade_evento[i];
for (int i = 0; i < n; i++) cin >> dia_evento[i];
for (int i = 0; i < m; i++) cin >> tarefas[i];
memset (dp, -1, sizeof(dp));
int mn = -1e9;
for (int i = 0; i < n; i++) {
mn = max (mn, solve (i, 0, false, false));
}
cout << mn << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
135 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
128 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
127 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
127 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
127 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
129 ms |
262144 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
135 ms |
262148 KB |
Execution killed with signal 9 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |