Submission #604289

#TimeUsernameProblemLanguageResultExecution timeMemory
604289balbitBoxes with souvenirs (IOI15_boxes)C++14
Compilation error
0 ms0 KiB
#include "boxes.h"
#include <bits/stdc++.h>
using namespace std;


#define int ll

#define ll long long
#define pii pair<int, int>
#define f first
#define s second

#define FOR(i,a,b) for (int i = a; i<b; ++i) 
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)

#define MX(a,b) a = max(a,b)
#define MN(a,b) a = min(a,b)
#define SZ(x) (int)((x).size())
#define ALL(x) (x).begin(), (x).end()
#define pb push_back

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<":"<<#__VA_ARGS__<<"- ", _do(__VA_ARGS__)
template<typename T> void _do(T && x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T && x, S && ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif


vector<ll>get(vector<int> &a, int K) {
    sort(ALL(a));
    vector<ll>dp(SZ(a)+1);
    REP1(i, SZ(a)) {
        dp[i] = a[i-1]*2 + (i-K>=0?dp[i-K]:0);
    }
    return dp;
}


long long delivery(signed N, signed K, signed L, signed p[]) {

    vector<int>A, B;
    REP(i,N) {
        if(p[i] == 0)continue;
        if(p[i] <= L/2) {
            A.pb(p[i]);
        }else{
            B.pb(L-p[i]);
        }
    }
    MN(K, N);
    vector<ll>da = get(A,K), db = get(B,K);
    ll re = da.back() +db.back();
    MN(re, L);
    return re;
    for(int tka = 1; tka <K; ++tka) {
        int tkb = K - tka;
        if(tka <= SZ(A) && tkb <= SZ(B)) {
            ll hi = L + da[SZ(da) - tka-1] + db[SZ(db) - tkb - 1];
            bug(tka, hi);
            MN(re, hi);
        }
    }
    bug(re);
    return re;
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:18:28: error: no matching function for call to 'min(long long int&, int&)'
   18 | #define MN(a,b) a = min(a,b)
      |                            ^
boxes.cpp:57:5: note: in expansion of macro 'MN'
   57 |     MN(re, L);
      |     ^~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:18:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 | #define MN(a,b) a = min(a,b)
      |                            ^
boxes.cpp:57:5: note: in expansion of macro 'MN'
   57 |     MN(re, L);
      |     ^~
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:18:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   18 | #define MN(a,b) a = min(a,b)
      |                            ^
boxes.cpp:57:5: note: in expansion of macro 'MN'
   57 |     MN(re, L);
      |     ^~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
boxes.cpp:18:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 | #define MN(a,b) a = min(a,b)
      |                            ^
boxes.cpp:57:5: note: in expansion of macro 'MN'
   57 |     MN(re, L);
      |     ^~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from boxes.cpp:2:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
boxes.cpp:18:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   18 | #define MN(a,b) a = min(a,b)
      |                            ^
boxes.cpp:57:5: note: in expansion of macro 'MN'
   57 |     MN(re, L);
      |     ^~