Submission #1247408

#TimeUsernameProblemLanguageResultExecution timeMemory
1247408fskarica메기 농장 (IOI22_fish)C++20
Compilation error
0 ms0 KiB
#include "fish.h"
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define fi first
#define se second
#define pii pair<int, int>

int n, m;
vector <int> vx, vy, w;

ll max_weights(int N, int M, vector<int> X, vector<int> Y, vector<int> W) {
    n = N, m = M, vx = X, vy = Y, w = W;

    vector <pii> v0, v1;

    ll zbr = 0;
    for (int i = 0; i < m; i++) {
        if (vx[i] == 0) v0.push_back({vy[i], w[i]});
        else v1.push_back({vy[i], w[i]}), zbr += w[i];
    }

    sort(v0,begin(), v0.end());
    sort(v1,begin(), v1.end());

    int pos = 0;
    ll ret = zbr;
    for (auto e : v0) {
        while (pos < v1.size() && v1[pos].fi <= e.fi) {
            zbr -= v1[pos].se;
            pos++;
        }
        zbr += e.se;

        ret = max(ret, zbr);
    }

    return ret;
}

Compilation message (stderr)

fish.cpp: In function 'long long int max_weights(int, int, std::vector<int>, std::vector<int>, std::vector<int>)':
fish.cpp:25:18: error: no matching function for call to 'begin()'
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/vector:62,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   90 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/11/initializer_list:90:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   90 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from fish.cpp:2:
/usr/include/c++/11/valarray:1217:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1217 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1217:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from fish.cpp:2:
/usr/include/c++/11/valarray:1228:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1228:5: note:   template argument deduction/substitution failed:
fish.cpp:25:18: note:   candidate expects 1 argument, 0 provided
   25 |     sort(v0,begin(), v0.end());
      |             ~~~~~^~
fish.cpp:26:18: error: no matching function for call to 'begin()'
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/bits/algorithmfwd.h:39,
                 from /usr/include/c++/11/bits/stl_algo.h:60,
                 from /usr/include/c++/11/vector:62,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/initializer_list:90:5: note: candidate: 'template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>)'
   90 |     begin(initializer_list<_Tp> __ils) noexcept
      |     ^~~~~
/usr/include/c++/11/initializer_list:90:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:51:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(_Container&)'
   51 |     begin(_Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:51:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:61:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.begin()) std::begin(const _Container&)'
   61 |     begin(const _Container& __cont) -> decltype(__cont.begin())
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:61:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/c++/11/vector:69,
                 from fish.h:1,
                 from fish.cpp:1:
/usr/include/c++/11/bits/range_access.h:90:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::begin(_Tp (&)[_Nm])'
   90 |     begin(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~~~
/usr/include/c++/11/bits/range_access.h:90:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from fish.cpp:2:
/usr/include/c++/11/valarray:1217:5: note: candidate: 'template<class _Tp> _Tp* std::begin(std::valarray<_Tp>&)'
 1217 |     begin(valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1217:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~
In file included from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:95,
                 from fish.cpp:2:
/usr/include/c++/11/valarray:1228:5: note: candidate: 'template<class _Tp> const _Tp* std::begin(const std::valarray<_Tp>&)'
 1228 |     begin(const valarray<_Tp>& __va) noexcept
      |     ^~~~~
/usr/include/c++/11/valarray:1228:5: note:   template argument deduction/substitution failed:
fish.cpp:26:18: note:   candidate expects 1 argument, 0 provided
   26 |     sort(v1,begin(), v1.end());
      |             ~~~~~^~