Submission #542238

# Submission time Handle Problem Language Result Execution time Memory
542238 2022-03-25T22:55:04 Z rembocoder Distributing Candies (IOI21_candies) C++17
Compilation error
0 ms 0 KB
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#include <bits/stdc++.h>

using namespace std;

#define int int64_t
#define forn(i, n) for (int i = 0; i < (int)(n); i++)

struct my_hash {
    inline size_t operator()(const pair<int, int>& a) const {
        return a.first * 31 + a.second;
    }
};

vector<int> distribute_candies(vector<int> c, vector<int> l, vector<int> r, vector<int> v) {
    int n = c.size();
    int m = l.size();
    vector<int> res(n);
    for (int i = 0; i < m; i++) {
        for (int j = l[i]; j <= r[i]; j++) {
            res[j] += v[i];
            res[j] = max(0ll, res[j]);
            res[j] = min(c[j], res[j]);
        }
    }
    return c;
}

/*int32_t main() {
    ios_base::sync_with_stdio(0);
    int t = 1;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;
        vector<int> a(n);
        for (int i = 0; i < n; i++) {
            cin >> a[i];
        }
        sort(a.begin(), a.end());
        int sum_a0 = 0;
        for (int i = 1; i < n; i++) {
            sum_a0 += a[0] + a[i];
        }
        int sum_ab = 0;
        for (int i = 0; i < n - 1; i++) {
            sum_ab += a[i] + a.back();
        }
        if (sum_a0 > 0 || sum_ab < 0) {
            cout << "INF\n";
            continue;
        }
        vector<int> sum(n + 1);
        for (int i = 0; i < n; i++) {
            sum[i + 1] = sum[i] + a[i];
        }
        int ans = -2e18;
        for (int i = 0; i < n; i++) {
            int cur = -a[i] * a[i] * (n - 1);
            cur += (sum[n] - sum[i + 1] - a[i] * (n - i - 1)) * (a[0] - a[i]);
            cur += (sum[i] - sum[1] - a[i] * (i - 1)) * (a[n - 1] - a[i]);
            ans = max(ans, cur);
        }
        cout << ans << '\n';
    }
    return 0;
}
*/

Compilation message

candies.cpp:2: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    2 | #pragma GCC optimization ("O3")
      | 
candies.cpp:3: warning: ignoring '#pragma GCC optimization' [-Wunknown-pragmas]
    3 | #pragma GCC optimization ("unroll-loops")
      | 
candies.cpp: In function 'std::vector<long int> distribute_candies(std::vector<long int>, std::vector<long int>, std::vector<long int>, std::vector<long int>)':
candies.cpp:26:37: error: no matching function for call to 'max(long long int, __gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type&)'
   26 |             res[j] = max(0ll, res[j]);
      |                                     ^
In file included from /usr/include/c++/10/memory:63,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from candies.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
candies.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   26 |             res[j] = max(0ll, res[j]);
      |                                     ^
In file included from /usr/include/c++/10/memory:63,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:44,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from candies.cpp:4:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
candies.cpp:26:37: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<long int>, long int>::value_type' {aka 'long int'})
   26 |             res[j] = max(0ll, res[j]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/c++/10/ext/pb_ds/hash_policy.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from candies.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
candies.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |             res[j] = max(0ll, res[j]);
      |                                     ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/c++/10/ext/pb_ds/hash_policy.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/detail/standard_policies.hpp:45,
                 from /usr/include/c++/10/ext/pb_ds/assoc_container.hpp:47,
                 from candies.cpp:4:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
candies.cpp:26:37: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   26 |             res[j] = max(0ll, res[j]);
      |                                     ^