Submission #1056106

#TimeUsernameProblemLanguageResultExecution timeMemory
1056106Halym2007Road Closures (APIO21_roads)C++17
7 / 100
35 ms8732 KiB
#include <bits/stdc++.h> #include "roads.h" using namespace std; #define ll long long #define sz size() #define ff first #define ss second #define pb push_back #define pii pair <ll, ll> const int N = 2e5 + 5; vector <pair <ll, pii>> v, q; vector <ll> jog, jogap; int deg[N]; ll dp[N]; vector<long long> minimum_closure_costs(int n, vector<int> l, vector<int> r, vector<int> w) { ll sum = 0, sum1 = 0, sum2 = 0; for (int i = 0; i < n - 1; ++i) { sum += w[i]; if (i == 0) dp[i] = w[i]; else if (i == 1) { dp[i] = max (w[i - 1], w[i]); } else { dp[i] = max (dp[i - 1], w[i] + dp[i - 2]); } } jogap.pb(sum); jogap.pb (sum - dp[n - 2]); for (int i = 2; i < n; ++i) { jogap.pb(0); } return jogap; } //int main() { // freopen ("input.txt", "r", stdin); // int N; // assert(1 == scanf("%d", &N)); // // std::vector<int> U(N - 1), V(N - 1), W(N - 1); // for (int i = 0; i < N - 1; ++i) { // assert(3 == scanf("%d %d %d", &U[i], &V[i], &W[i])); // } // // std::vector<long long> closure_costs = minimum_closure_costs(N, U, V, W); // for (int i = 0; i < static_cast<int>(closure_costs.size()); ++i) { // if (i > 0) { // printf(" "); // } // printf("%lld",closure_costs[i]); // } // printf("\n"); // return 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:17:14: warning: unused variable 'sum1' [-Wunused-variable]
   17 |  ll sum = 0, sum1 = 0, sum2 = 0;
      |              ^~~~
roads.cpp:17:24: warning: unused variable 'sum2' [-Wunused-variable]
   17 |  ll sum = 0, sum1 = 0, sum2 = 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...