Submission #729822

# Submission time Handle Problem Language Result Execution time Memory
729822 2023-04-24T16:30:50 Z caganyanmaz Catfish Farm (IOI22_fish) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
using namespace std;

int max_weights(int n, int m, vector<int> x, vector<int> y, vector<int> w)
{
        array<vector<array<int, 2>>, 2> t;
        for (int i = 0; i < m; i++)
                if (x[i] <= 1)
                        t[x[i]].pb({y[i], w[i]});
                else
                        assert(false);
        for (int i = 0; i < 2; i++)
                sort(t[i].begin(), t[i].end());
        array<vector<int>, 2> p;
        for (int i = 0; i < 2; i++)
        {
                p[i] = vector<int>(n+1);
                int _next = 0;
                for (int j = 1; j <= n; j++)
                {
                        p[i][j] = p[i][j-1];
                        if (_next < t[i].size() && j > t[i][_next][0])
                                p[i][j] += t[i][_next++][1];
                }
        }
        int best = 0;
        for (int i = 0; i <= n; i++)
                best = max(best, p[0][i] + p[1][n] - p[1][i]);
        return best;
}

Compilation message

fish.cpp: In function 'int64_t max_weights(int64_t, int64_t, std::vector<long int>, std::vector<long int>, std::vector<long int>)':
fish.cpp:24:35: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::vector<std::array<long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   24 |                         if (_next < t[i].size() && j > t[i][_next][0])
      |                             ~~~~~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc9I8TuV.o: in function `main':
grader.cpp:(.text.startup+0x25e): undefined reference to `max_weights(int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status