Submission #1082751

#TimeUsernameProblemLanguageResultExecution timeMemory
1082751blackslexRoad Closures (APIO21_roads)C++17
7 / 100
26 ms7636 KiB
#include "roads.h" #include <vector> #include<bits/stdc++.h> using namespace std; using ll = long long; const int MxN = 25e4 + 5; ll a[MxN], dp[MxN]; std::vector<long long> minimum_closure_costs(int N, std::vector<int> U, std::vector<int> V, std::vector<int> W) { int n = N, m = U.size(); ll res = 0, cur = 0; for (int i = 0; i < m; i++) res += W[i], a[i + 1] = W[i]; vector<ll> ans{res}; for (int i = 1; i <= m; i++) dp[i] = max(dp[i - 1], (i - 2 >= 0 ? dp[i - 2] : 0) + a[i]); ans.emplace_back(res - dp[m]); for (int i = 2; i < n; i++) ans.emplace_back(0); 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:16:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   16 |   for (int i = 1; i <= m; i++) dp[i] = max(dp[i - 1], (i - 2 >= 0 ? dp[i - 2] : 0) + a[i]); ans.emplace_back(res - dp[m]);
      |   ^~~
roads.cpp:16:93: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   16 |   for (int i = 1; i <= m; i++) dp[i] = max(dp[i - 1], (i - 2 >= 0 ? dp[i - 2] : 0) + a[i]); ans.emplace_back(res - dp[m]);
      |                                                                                             ^~~
roads.cpp:13:15: warning: unused variable 'cur' [-Wunused-variable]
   13 |   ll res = 0, cur = 0;
      |               ^~~
#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...