Submission #1130119

#TimeUsernameProblemLanguageResultExecution timeMemory
1130119Art_ogoBoxes with souvenirs (IOI15_boxes)C++17
Compilation error
0 ms0 KiB
#ifdef ONPC
    #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

#ifndef ONPC
    #pragma GCC target("avx2")
    #pragma GCC target("popcnt")

    #define cerr if (false) cerr
#endif

#define all(v) v.begin(), v.end()
#define watch(x) cerr << #x << ':' << x << endl;

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> Pint;
typedef pair<ll, ll> Pll;

typedef __int128_t int128;

mt19937_64 gen64(chrono::steady_clock::now().time_since_epoch().count());
inline ll rnd(ll l = LLONG_MIN, ll r = LLONG_MAX) {
    return uniform_int_distribution<ll>(l, r)(gen64);
}

const int mod = 1e9 + 7;

inline int mult(int a, int b) {
    return (1LL * a * b) % mod;
}

template<class T>
bool umax(T &a, const T &b) {
    return (a < b ? a = b, true : false);
}

const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;

const int maxn = 1e5 + 10, maxm = 20, maxc = 5000 + 10, maxq = 2e5 + 10, logn = 20, msqn = 45, cpr = 500, maxbit = 32;

long long delivery(int n, int k, int l, int P[]) {
    vector<int> a(n);
    for(int i = 0; i < n; i++)
      a[i] = P[i];

    vector<int> p, q;
    for (auto i : a) {
        if (l - i < i) {
            q.push_back(l - i);
        } else {
            p.push_back(i);
        }
    }

    sort(all(p), greater<>());
    sort(all(q));

    int left = n;
    ll ans = 0;
    while (left > 0) {
        bool ptaken = false, qtaken = false;
        ll s = 0;
        int plast = 0;
        for (int i = 0; i < k && left > 0; ++i) {
            if (!p.empty()) {
                s += p.back() - plast;
                ptaken = true;
                plast = p.back();
                p.pop_back();
                left--;
            } else {
                if (ptaken) {
                    if ((l - q.back()) - plast < q.back()) {
                        s += (l - q.back()) - plast;
                        plast = l - q.back();
                        q.pop_back();
                        left--;
                    } else {
                        break;
                    }
                } else {
                    if (!qtaken) {
                        s = q.back();
                    }
                    qtaken = true;
                    q.pop_back();
                    left--;
                }
            }
        }
        ans += min(2 * s, l);
    }

    cout << ans << '\n';
}

Compilation message (stderr)

boxes.cpp: In function 'long long int delivery(int, int, int, int*)':
boxes.cpp:97:19: error: no matching function for call to 'min(ll, int&)'
   97 |         ans += min(2 * s, l);
      |                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from boxes.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
boxes.cpp:97:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   97 |         ans += min(2 * s, l);
      |                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from boxes.cpp:4:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
boxes.cpp:97:19: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   97 |         ans += min(2 * s, l);
      |                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from boxes.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
boxes.cpp:97:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   97 |         ans += min(2 * s, l);
      |                ~~~^~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from boxes.cpp:4:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
boxes.cpp:97:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   97 |         ans += min(2 * s, l);
      |                ~~~^~~~~~~~~~
boxes.cpp:101:1: warning: no return statement in function returning non-void [-Wreturn-type]
  101 | }
      | ^