답안 #690467

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
690467 2023-01-30T08:12:59 Z Dan4Life 도로 폐쇄 (APIO21_roads) C++17
12 / 100
50 ms 7220 KB
#include "roads.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
using ll = long long;
const int maxn = (int)2e5+10;
const int INF = (int)1e9;

vector<ll> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) {
    vector<ll> ans(N,0ll);
    ans[0] = accumulate(all(W),0ll);
    if(accumulate(all(U),0ll)==0ll){
        sort(all(W)); reverse(all(W)); int i = 0;
        ll tot = accumulate(all(W),0ll);
        for(auto &u : ans) u=tot,tot-=W[i++];
        return ans;
    }
    ll dp[N-1][2];
    dp[0][0] = dp[0][1] = 0;
    for(int i = 1; i < N; i++){
        dp[i][0] = min(dp[i-1][1],dp[i-1][0])+W[i-1];
        dp[i][1] = dp[i-1][0];
    }
    ans[1] = min(dp[N-1][0],dp[N-1][1]);
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 24 ms 2132 KB Output is correct
13 Correct 38 ms 3396 KB Output is correct
14 Correct 42 ms 3312 KB Output is correct
15 Correct 46 ms 3620 KB Output is correct
16 Correct 50 ms 3632 KB Output is correct
17 Correct 45 ms 3748 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 30 ms 3044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 37 ms 4096 KB Output is correct
3 Correct 39 ms 6636 KB Output is correct
4 Correct 45 ms 7064 KB Output is correct
5 Correct 41 ms 7220 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 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 304 KB Output is correct
12 Correct 21 ms 3812 KB Output is correct
13 Correct 35 ms 6336 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 32 ms 5696 KB Output is correct
16 Correct 46 ms 6324 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 0 ms 212 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 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 33 ms 4820 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 24 ms 2132 KB Output is correct
13 Correct 38 ms 3396 KB Output is correct
14 Correct 42 ms 3312 KB Output is correct
15 Correct 46 ms 3620 KB Output is correct
16 Correct 50 ms 3632 KB Output is correct
17 Correct 45 ms 3748 KB Output is correct
18 Correct 0 ms 212 KB Output is correct
19 Correct 30 ms 3044 KB Output is correct
20 Correct 0 ms 212 KB Output is correct
21 Correct 37 ms 4096 KB Output is correct
22 Correct 39 ms 6636 KB Output is correct
23 Correct 45 ms 7064 KB Output is correct
24 Correct 41 ms 7220 KB Output is correct
25 Correct 1 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 21 ms 3812 KB Output is correct
32 Correct 35 ms 6336 KB Output is correct
33 Correct 0 ms 212 KB Output is correct
34 Correct 32 ms 5696 KB Output is correct
35 Correct 46 ms 6324 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Incorrect 0 ms 212 KB Output isn't correct
38 Halted 0 ms 0 KB -