# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
394401 |
2021-04-26T13:52:36 Z |
iulia13 |
Raisins (IOI09_raisins) |
C++14 |
|
944 ms |
52284 KB |
#include <iostream>
using namespace std;
const int C = 51;
int dp[C][C][C][C];
int a[C][C];
int main()
{
int n, m, i, j, ii, jj;
cin >> n >> m;
for (i = 1; i <= n; i++)
for (j = 1; j <= m; j++)
{
cin >> a[i][j];
a[i][j] += (a[i][j - 1] + a[i - 1][j] - a[i - 1][j - 1]);
for (ii = 1; ii <= n; ii++)
for (jj = 1; jj <= m; jj++)
dp[i][j][ii][jj] = 1e9;
}
for (i = 1; i <= n; i++)
for (j = 1; j <= m; j++)
dp[i][j][i][j] = 0;
for (int l = 1; l <= n + m - 2; l++)
for (int x1 = 1; x1 <= n; x1++)
for (int y1 = 1; y1 <= n; y1++)
for (int x2 = x1; x2 <= n && x2 - x1 <= l; x2++)
{
int y2 = y1 + (l - (x2 - x1));
int x = a[x2][y2] + a[x1 - 1][y1 - 1] - a[x1 - 1][y2] - a[x2][y1 - 1];
for (i = x1; i < x2; i++)
dp[x1][y1][x2][y2] = min(dp[x1][y1][x2][y2], dp[x1][y1][i][y2] + dp[i + 1][y1][x2][y2] + x);
for (i = y1; i < y2; i++)
dp[x1][y1][x2][y2] = min(dp[x1][y1][x2][y2], dp[x1][y1][x2][i] + dp[x1][i + 1][x2][y2] + x);
}
cout << dp[1][1][n][m];
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
204 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Incorrect |
1 ms |
332 KB |
Output isn't correct |
5 |
Correct |
1 ms |
588 KB |
Output is correct |
6 |
Correct |
1 ms |
844 KB |
Output is correct |
7 |
Correct |
2 ms |
1612 KB |
Output is correct |
8 |
Incorrect |
8 ms |
3404 KB |
Output isn't correct |
9 |
Correct |
27 ms |
5196 KB |
Output is correct |
10 |
Correct |
26 ms |
5892 KB |
Output is correct |
11 |
Incorrect |
14 ms |
4812 KB |
Output isn't correct |
12 |
Correct |
86 ms |
10640 KB |
Output is correct |
13 |
Correct |
148 ms |
12804 KB |
Output is correct |
14 |
Incorrect |
21 ms |
6132 KB |
Output isn't correct |
15 |
Correct |
205 ms |
14192 KB |
Output is correct |
16 |
Correct |
112 ms |
13104 KB |
Output is correct |
17 |
Correct |
253 ms |
16592 KB |
Output is correct |
18 |
Correct |
725 ms |
22384 KB |
Output is correct |
19 |
Correct |
944 ms |
24396 KB |
Output is correct |
20 |
Runtime error |
43 ms |
52284 KB |
Execution killed with signal 11 |