Submission #724938

#TimeUsernameProblemLanguageResultExecution timeMemory
724938yeysoRoad Closures (APIO21_roads)C++14
5 / 100
50 ms8476 KiB
#include "roads.h" #include <bits/stdc++.h> using namespace std; using ll = long long; vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { int n = N; vector<int> u = U; vector<int> v = V; vector<ll> w; for(int i = 0; i < W.size(); i ++){ w.push_back(W[i]); } vector<ll> res(n, 0); // k = 0 for(int i = 0; i < w.size(); i ++){ res[0] += w[i]; } // else sort(w.begin(), w.end()); vector<ll> prefix(w.size(), 0); for(int i = 0; i < w.size(); i ++){ if(i >= 1){ prefix[i] = prefix[i-1] + w[i]; } else{ prefix[0] = w[0]; } } reverse(prefix.begin(), prefix.end()); prefix.push_back(0); return prefix; } /* g++ -std=gnu++17 -O2 -pipe -o roads grader.cpp roads.cpp 6 0 1 3 0 2 2 0 3 1 0 4 4 0 5 1 */ /* // k = 1; vector<ll> dp(n-1, 0); for(int i = 0; i < w.size(); i ++){ if(i >= 1){ if(i >= 2){ dp[i] = max(dp[i-1], dp[i-2]+w[i]); } else { dp[i] = max(dp[i-1], w[i]); } } else { dp[i] = w[i]; } } res[1] = res[0] - dp[dp.size() - 1];*/

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:11:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i = 0; i < W.size(); i ++){
      |                    ~~^~~~~~~~~~
roads.cpp:17:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i = 0; i < w.size(); i ++){
      |                    ~~^~~~~~~~~~
roads.cpp:23:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for(int i = 0; i < w.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...