Submission #850346

# Submission time Handle Problem Language Result Execution time Memory
850346 2023-09-16T12:23:17 Z AliHasanli Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include "fish.h"
#include <vector>
using namespace std;
long long max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W)
{
    if(n==1)
        return 0;
    bool check=true;
    int maxX=0;
    for(int i:X)
        maxX=max(maxX,X[i]);
    for(int i:X)
        if(i%2)
        {
            check=false;
            break;
        }
    long long ans=0;
    if(check)
    {
        for(int i=0;i<W.size();i++)
        ans+=W[i];
        return ans;
    }
    else if(maxX==0)
    {
        for(int i=0;i<W.size();i++)
        ans+=W[i];
        return ans;
    }
    else if(maxX==1)
    {
        long long ansX0=0,ansX1=0;
        for(int i=0;i<=M;i++)
            if(X[i]==0)
                ansX0+=W[i];
            else 
                ansX1+=W[i];
        return max(ansX0,ansX1);
    }
    return 0;
}

Compilation message

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:6:8: error: 'n' was not declared in this scope
    6 |     if(n==1)
      |        ^
fish.cpp:21:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~
fish.cpp:27:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |         for(int i=0;i<W.size();i++)
      |                     ~^~~~~~~~~