제출 #994869

#제출 시각아이디문제언어결과실행 시간메모리
994869thelegendary08도로 폐쇄 (APIO21_roads)C++14
5 / 100
34 ms7632 KiB
#include "roads.h" #include<bits/stdc++.h> #define f0r(i,n) for(int i = 0;i<n;i++) #define pb push_back #define ll long long int #define vi vector<ll> using namespace std; std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { vi r(N, 0); f0r(i,N-1){ r[U[i]]++; r[V[i]]++; } vector<long long int> ans; vi w; f0r(i,N-1)w.pb(W[i]); if(r[0] == N-1){ sort(w.begin(), w.end()); ll sum = 0; ans.pb(0); f0r(i,N-1){ sum += w[i]; ans.pb(sum); } reverse(ans.begin(), ans.end()); } else{ ll sum = 0; f0r(i, N-1)sum += w[i]; ans.pb(sum); ll od = 0; ll ev = 0; f0r(i, N-1){ if(i % 2 == 0)ev += w[i]; else od += w[i]; } ans.pb(min(ev, od)); for(int i = 2;i<N;i++)ans.pb(0); } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...