Submission #496163

#TimeUsernameProblemLanguageResultExecution timeMemory
496163f4t4ntKnapsack (NOI18_knapsack)C++11
Compilation error
0 ms0 KiB
#include <algorithm>
#include <cmath>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <unordered_set>
#include <utility>
#include <vector>

#define ll long long
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>
#define vvvvl vector<vvvl>
#define vpll vector<pll>
#define vvpll vector<vpll>
#define plvl pair<ll, vl>
#define vplvl vector<plvl>
#define sl set<ll>
#define spll set<pll>
#define vsl vector<sl>
#define ssl set<sl>
#define plsl pair<ll, sl>
#define vplsl vector<plsl>
#define msl multiset<ll>
#define mspll multiset<pll>
#define vb vector<bool>
#define vvb vector<vb>
#define mll map<ll, ll>
#define mlll map<ll, mll>
#define mlvl map<ll, vl>
#define mlpll map<ll, pll>
#define mlvpll map<ll, vpll>
#define mlsl map<ll, sl>
#define mpllb map<pll, bool>
#define vmll vector<mll>
#define ql queue<ll>
#define qpll queue<pll>
#define fl float
#define vf vector<fl>
#define vvf vector<vf>
#define str string
#define vstr vector<str>
#define mstrl map<str, ll>

#define pb push_back
#define elif else if
#define sz(C) (ll) C.size()
#define flip(C) reverse(C.begin(), C.end())
#define ssort(C) sort(C.begin(), C.end())
#define rsort(C) sort(C.begin(), C.end(), greater<>())
#define max_elem(C) *max_element(C.begin(), C.end())
#define min_elem(C) *min_element(C.begin(), C.end())

#define FOR(x, e) for(ll  x = 0; x < (ll) e; x++)
#define FORR(x, e) for(ll x = (ll) e - 1; x >= 0; x--)
#define FOB(x, b, e) for(auto x = (ll) b; x != (ll) e; x++)
#define FOE(x, e, b) for(auto x = (ll) e - 1; x >= (ll) b; x--)
#define FOI(x, e, i) for(ll x = 0; x < (ll) e; x += (ll) i)
#define FORE(x, C) for(auto& x : C)

using namespace std;

int main()
{
    ll S, N;
    cin >> S >> N;
    mlvpll W;
    FOR(n, N)
    {
        ll v, w, k;
        cin >> v >> w >> k;
        W[w].pb({ v, k });
    }
    ll M = sz(W) + 1;
    S++;
    vvl dp(M, vl(S));
    ll m = 1;
    FORE(x, W)
    {
        ll w = x.first;
        vpll &v = x.second;
        rsort(v);
        dp[m] = dp[m - 1];
        FOR(s, S)
        {
            ll i = 1, j = 0, k = 0, p = 0;
            while(i * w <= s && j < sz(v))
            {
                p += v[j].first;
                dp[m][s] = max(dp[m][s], dp[m - 1][s - i * w] + p);
                i++; k++;
                if(k == v[j].second)
                { k = 0; j++; }
            }
        }
        m++;
    }
    cout << max_elem(dp[M - 1]) << '\n';
}

Compilation message (stderr)

knapsack.cpp: In function 'int main()':
knapsack.cpp:70:51: error: wrong number of template arguments (0, should be 1)
   70 | #define rsort(C) sort(C.begin(), C.end(), greater<>())
      |                                                   ^
knapsack.cpp:102:9: note: in expansion of macro 'rsort'
  102 |         rsort(v);
      |         ^~~~~
In file included from /usr/include/c++/10/string:48,
                 from /usr/include/c++/10/bits/locale_classes.h:40,
                 from /usr/include/c++/10/bits/ios_base.h:41,
                 from /usr/include/c++/10/ios:42,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/fstream:38,
                 from knapsack.cpp:5:
/usr/include/c++/10/bits/stl_function.h:371:12: note: provided for 'template<class _Tp> struct std::greater'
  371 |     struct greater : public binary_function<_Tp, _Tp, bool>
      |            ^~~~~~~