#include <cstdio>
#include <algorithm>
using namespace std;
int a[305],n;
int dp[305][205][205];
int main(){
scanf("%d",&n);
for (int i=0; i<n; i++) {
scanf("%d",&a[i]);
}
for (int i=n-1; i>=0; i--) {
for (int j=0; j<=a[i]; j++) {
for (int k=0; k<=a[i+1]; k++) {
dp[i][j][k] = 1e9;
for (int l=0; l<=j && l<=k; l++) {
for (int m=0; m<=a[i+2] && m<=l; m++) {
dp[i][j][k] = min(dp[i][j][k],3 * j + 2 * l + 2 * m + dp[i+1][k-l][a[i+2]-m]);
}
}
}
}
}
printf("%d",dp[0][a[0]][a[1]]);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
51152 KB |
Output is correct |
2 |
Correct |
0 ms |
51152 KB |
Output is correct |
3 |
Correct |
0 ms |
51152 KB |
Output is correct |
4 |
Correct |
0 ms |
51152 KB |
Output is correct |
5 |
Correct |
0 ms |
51152 KB |
Output is correct |
6 |
Correct |
0 ms |
51152 KB |
Output is correct |
7 |
Correct |
3 ms |
51152 KB |
Output is correct |
8 |
Correct |
31 ms |
51152 KB |
Output is correct |
9 |
Correct |
206 ms |
51152 KB |
Output is correct |
10 |
Correct |
571 ms |
51152 KB |
Output is correct |
11 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
12 |
Correct |
1288 ms |
51152 KB |
Output is correct |
13 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
14 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
15 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
16 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
17 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
18 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
19 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |
20 |
Execution timed out |
2000 ms |
51148 KB |
Program timed out |