Submission #1116577

#TimeUsernameProblemLanguageResultExecution timeMemory
1116577PagodePaivaRoad 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) { long long 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 <long long> 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: conflicting declaration 'int res'
   17 |     int res = 0;
      |         ^~~
roads.cpp:10:15: note: previous declaration as 'long long int res'
   10 |     long long res = 0;
      |               ^~~