# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
72940 |
2018-08-27T09:17:12 Z |
Navick |
Wiring (IOI17_wiring) |
C++17 |
|
46 ms |
4796 KB |
#include <bits/stdc++.h>
#include "wiring.h"
#define F first
#define S second
#define pii pair <int, int>
#define pb push_back
using namespace std;
typedef long long ll;
const int maxN = 210;
const ll oo = 1e16;
ll dp[maxN][maxN];
long long min_total_length(std::vector<int> r, std::vector<int> b) {
int n = r.size(), m = b.size();
dp[0][0] = 0;
for (int j=1; j<=m; j++) dp[0][j] = oo;
for (int i=1; i<=n; i++) dp[i][0] = oo;
for (int i=1; i<=n; i++)
for (int j=1; j<=m; j++)
{
ll curr = 0;
dp[i][j] = oo;
for (int k=j-1; k>=0; k--)
{
curr += abs(r[i - 1] - b[k]);
dp[i][j] = min(dp[i][j], curr + dp[i - 1][k]);
}
curr = 0;
for (int k=i-1; k>=0; k--)
{
curr += abs(b[j - 1] - r[k]);
dp[i][j] = min(dp[i][j], curr + dp[k][j - 1]);
}
}
return dp[n][m];
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
3 ms |
544 KB |
Output is correct |
7 |
Correct |
25 ms |
976 KB |
Output is correct |
8 |
Correct |
25 ms |
976 KB |
Output is correct |
9 |
Correct |
28 ms |
976 KB |
Output is correct |
10 |
Correct |
20 ms |
976 KB |
Output is correct |
11 |
Correct |
21 ms |
976 KB |
Output is correct |
12 |
Correct |
23 ms |
976 KB |
Output is correct |
13 |
Correct |
26 ms |
976 KB |
Output is correct |
14 |
Correct |
25 ms |
976 KB |
Output is correct |
15 |
Correct |
26 ms |
976 KB |
Output is correct |
16 |
Correct |
27 ms |
996 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
996 KB |
Output is correct |
2 |
Correct |
11 ms |
996 KB |
Output is correct |
3 |
Runtime error |
29 ms |
3824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3824 KB |
Output is correct |
2 |
Correct |
3 ms |
3824 KB |
Output is correct |
3 |
Runtime error |
41 ms |
4524 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
4524 KB |
Output is correct |
2 |
Runtime error |
46 ms |
4796 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
248 KB |
Output is correct |
2 |
Correct |
3 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
448 KB |
Output is correct |
4 |
Correct |
2 ms |
468 KB |
Output is correct |
5 |
Correct |
2 ms |
544 KB |
Output is correct |
6 |
Correct |
3 ms |
544 KB |
Output is correct |
7 |
Correct |
25 ms |
976 KB |
Output is correct |
8 |
Correct |
25 ms |
976 KB |
Output is correct |
9 |
Correct |
28 ms |
976 KB |
Output is correct |
10 |
Correct |
20 ms |
976 KB |
Output is correct |
11 |
Correct |
21 ms |
976 KB |
Output is correct |
12 |
Correct |
23 ms |
976 KB |
Output is correct |
13 |
Correct |
26 ms |
976 KB |
Output is correct |
14 |
Correct |
25 ms |
976 KB |
Output is correct |
15 |
Correct |
26 ms |
976 KB |
Output is correct |
16 |
Correct |
27 ms |
996 KB |
Output is correct |
17 |
Correct |
3 ms |
996 KB |
Output is correct |
18 |
Correct |
11 ms |
996 KB |
Output is correct |
19 |
Runtime error |
29 ms |
3824 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
20 |
Halted |
0 ms |
0 KB |
- |