Submission #613770

#TimeUsernameProblemLanguageResultExecution timeMemory
613770AugustinasJucasRoad Closures (APIO21_roads)C++14
7 / 100
50 ms12256 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; const int dydis = 1e5 + 10; vector<pair<int, int> > gr[dydis]; int n, m; vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { n = N; m = W.size(); bool line = true, star = true; vector<int> mas; for(int i = 0; i < m; i++) { int a = U[i]; int b = V[i]; int w = W[i]; if(a != b-1) line = false; gr[a].push_back({b, w}); gr[b].push_back({a, w}); mas.push_back(w); } if(line) { /// Galiu praleisti max 1 is eiles. Kokia min suma? long long dp[n]; /// dp[i] - turiu visus iki i ir i-aji emiau. Kokia min suma? dp[0] = mas[0]; dp[1] = mas[1]; for(int i = 2; i < n; i++) { dp[i] = min(dp[i-1] + mas[i], dp[i-2] + mas[i]); } vector<long long> ret(n, 0); for(auto x : mas) ret[0] += x; ret[1] = min(dp[n-1], dp[n-2]); return ret; } return vector<long long>(N, 0); }

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:12:23: warning: unused variable 'star' [-Wunused-variable]
   12 |     bool line = true, star = true;
      |                       ^~~~
#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...