Submission #729823

# Submission time Handle Problem Language Result Execution time Memory
729823 2023-04-24T16:31:58 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(int32_t n, int32_t m, vector<int32_t> x, vector<int32_t> y, vector<int32_t> 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;
}

int32_t main()
{
        vector<int> x = {0, 0, 0, 1, 1, 1};
        vector<int> y = {0, 2, 4, 1, 3, 5};
        vector<int> w = {3, 5, 7, 8, 2, 9};
        cout << max_weights(10, 6, x, y, w) << "\n";
}

Compilation message

fish.cpp: In function 'int64_t max_weights(int32_t, int32_t, std::vector<int>, std::vector<int>, std::vector<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])
      |                             ~~~~~~^~~~~~~~~~~~~
fish.cpp: In function 'int32_t main()':
fish.cpp:39:36: error: could not convert 'x' from 'vector<long int>' to 'vector<int>'
   39 |         cout << max_weights(10, 6, x, y, w) << "\n";
      |                                    ^
      |                                    |
      |                                    vector<long int>