Submission #555958

#TimeUsernameProblemLanguageResultExecution timeMemory
555958aryan12Road Closures (APIO21_roads)C++17
0 / 100
46 ms10336 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; const long long MAXN = 1e5 + 5; vector<array<long long, 2> > g[MAXN]; vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { long long sum = 0; vector<long long> weights; for(long long i = 0; i < U.size(); i++) { sum += W[i]; // cout << "U[i] = " << U[i] << ", V[i] = " << V[i] << ", W[i] = " << W[i] << "\n"; weights.push_back(W[i]); } vector<long long> ans; ans.push_back(sum); vector<long long> dp(N - 1, 0); dp[0] = weights[0]; dp[1] = weights[1]; for(int i = 2; i < N; i++) { dp[i] = min(dp[i - 2], dp[i - 1]) + weights[i]; } ans.push_back(min(dp[N - 1], dp[N - 2])); for(int i = 2; i < N; i++) { ans.push_back(0LL); } 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:12:28: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |     for(long long i = 0; i < U.size(); i++)
      |                          ~~^~~~~~~~~~
#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...