제출 #981356

#제출 시각아이디문제언어결과실행 시간메모리
981356Jawad_Akbar_JJ도로 폐쇄 (APIO21_roads)C++17
12 / 100
43 ms6640 KiB
#include <iostream> #include <vector> #include <algorithm> #include "roads.h" using namespace std; #define ll long long const int N = 1e5 + 10; vector<pair<int,int>> nei[N]; vector<ll> sub1(int n,vector<int> W){ sort(rbegin(W),rend(W)); vector<ll> v; v.push_back(0); for (int i : W) v[0] += i; for (int i : W) v.push_back(v.back() - i); return v; } vector<ll> sub2(int n,vector<int> W){ ll t = W[0]; ll nt = 0; vector<ll> v(n,0); v[0] += W[0]; for (int i=1;i<n-1;i++){ ll a = t; t = min(t,nt) + W[i]; nt = a; v[0] += W[i]; } v[1] = min(t,nt); return v; } vector<ll> minimum_closure_costs(int n,vector<int> U,vector<int> V,vector<int> W){ long long sum = 0,sum2 = 0,sum3 = 0; for (int i=0;i<n-1;i++) sum += U[i],sum2 += W[i],sum3 += (U[i] == i); if (sum == 0) return sub1(n,W); // if (sum2 == n-1) // return sub5(n,U,V); if (sum3 == n-1) return sub2(n,W); }

컴파일 시 표준 에러 (stderr) 메시지

roads.cpp: In function 'std::vector<long long int> minimum_closure_costs(int, std::vector<int>, std::vector<int>, std::vector<int>)':
roads.cpp:50:1: warning: control reaches end of non-void function [-Wreturn-type]
   50 | }
      | ^
#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...