Submission #724338

# Submission time Handle Problem Language Result Execution time Memory
724338 2023-04-15T06:05:31 Z raul2008487 Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"

#include <vector>

long long max_weights(int N, int M, std::vector<int> X, std::vector<int> Y, std::vector<int> W) {
    long long dp[W.size()];
    long long i;
    dp[0]=W[0];
    if(W[0]>W[1]){
        dp[1]=W[0];
    }
    else{
        dp[1]=W[1];
    }
    for(i=2;i<W.size();i++){
        dp[i]=max(dp[i-1],dp[i-2]+W[i]);
    }
    return dp[W.size()-1];
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:15:14: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     for(i=2;i<W.size();i++){
      |             ~^~~~~~~~~
fish.cpp:16:15: error: 'max' was not declared in this scope; did you mean 'std::max'?
   16 |         dp[i]=max(dp[i-1],dp[i-2]+W[i]);
      |               ^~~
      |               std::max
In file included from /usr/include/c++/10/vector:60,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~