#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
int i;
long long dp[100005][2];
vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
vector<long long> ans(N, 0LL);
for (i=0; i < N-1; ++i) ans[0] += (long long)W[i];
dp[0][0] = 0LL;
dp[0][1] = 0LL;
for (i=1; i < N; ++i) {
dp[i][1] = dp[i-1][0];
dp[i][0] = min(dp[i-1][0], dp[i-1][1])+(long long)W[i-1];
}
ans[1] = min(dp[N-1][0], dp[N-1][1]);
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
27 ms |
4120 KB |
Output is correct |
3 |
Correct |
35 ms |
6592 KB |
Output is correct |
4 |
Correct |
35 ms |
7100 KB |
Output is correct |
5 |
Correct |
38 ms |
7228 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
324 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
20 ms |
3908 KB |
Output is correct |
13 |
Correct |
32 ms |
6332 KB |
Output is correct |
14 |
Correct |
1 ms |
256 KB |
Output is correct |
15 |
Correct |
37 ms |
5680 KB |
Output is correct |
16 |
Correct |
39 ms |
6264 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
216 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
0 ms |
216 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
4784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
29 ms |
4784 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
340 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |