Submission #1116576

#TimeUsernameProblemLanguageResultExecution timeMemory
1116576PagodePaivaRoad Closures (APIO21_roads)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "roads.h" #include <vector> using namespace std; std::vector<long long> minimum_closure_costs(int n, std::vector<int> U, std::vector<int> V, std::vector<int> W) { int res = 0; vector <int> v; for(int i = 0;i < n-1;i++){ v.push_back(W[i]); } sort(v.begin(), v.end()); reverse(v.begin(), v.end()); int res = 0; vector <int> ans; ans.push_back(0); for(int k = n-2;k >= 0;k--){ res += v.back(); v.pop_back(); ans.push_back(res); } return ans; }

Compilation message (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:17:9: error: redeclaration of 'int res'
   17 |     int res = 0;
      |         ^~~
roads.cpp:10:9: note: 'int res' previously declared here
   10 |     int res = 0;
      |         ^~~
roads.cpp:25:12: error: could not convert 'ans' from 'vector<int>' to 'vector<long long int>'
   25 |     return ans;
      |            ^~~
      |            |
      |            vector<int>