Submission #1237096

#TimeUsernameProblemLanguageResultExecution timeMemory
1237096ericl23302나일강 (IOI24_nile)C++20
Compilation error
0 ms0 KiB
#include "nile.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pl pair<ll, ll>
#define pll pair<ll, pl>
#define ppl pair<pl, pl>

std::vector<long long> calculate_costs(std::vector<int> W, std::vector<int> A, std::vector<int> B, std::vector<int> E) {
    // int Q = E.size();
    // std::vector<long long> R(Q, 0);

    // int n = W.size();
    // vector<pair<ll, pair<ll, ll>>> items(n);
    // for (int i = 0; i < n; ++i) items[i] = {W[i], {A[i], B[i]}};
    // sort(items.begin(), items.end());

    // vector<ll> benefit(n);
    // for (int i = 0; i < n; ++i) benefit[i] = items[i].second.first - items[i].second.second;

    // int idx = 0;
    // for (auto &d : E) {
    //     vector<pll> dp(n + 1, {LLONG_MAX / 2, {LLONG_MAX / 2, -1}}); // {no unused: minCost, {one unused: minCost, one unused: index}}
    //     dp[0] = {0, {LLONG_MAX / 2, -1}};
    //     for (int i = 1; i <= n; ++i) {
    //         dp[i].first = dp[i - 1].first + items[i - 1].second.first;
    //         if (i < n && items[i].first - items[i - 1].first <= d) {
    //             // do nothing with current item
    //             dp[i].second = {dp[i - 1].first + items[i - 1].second.first, i - 1};
    //             if (dp[i - 1].second.first < LLONG_MAX / 2) {
    //                 pl other = {dp[i - 1].second.first + items[i - 1].second.first, i - 1};
    //                 if (items[i].first - items[dp[i - 1].second.second].first <= d && benefit[dp[i - 1].second.second] > benefit[i - 1]) other.second = dp[i - 1].second.second;
    //                 if (other.first < dp[i].second.first || (other.first == dp[i].second.first && benefit[other.second] > benefit[dp[i].second.second])) dp[i].second = other;
    //             }
    //         } 

    //         // combine with one unused
    //         if (dp[i - 1].second.first < LLONG_MAX / 2) dp[i].first = min(dp[i].first, dp[i - 1].second.first - items[dp[i - 1].second.second].second.first + items[dp[i - 1].second.second].second.second + items[i - 1].second.second);
    //     }

    //     R[idx++] = min(dp[n].first, dp[n].second.first);
    // }

    // return R;
    ll minBen = LLONG_MAX / 2;
    int n = W.size();
    ll res = 0;
    for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
    res += minBen;
    
    vector<ll> R(E.size(), res);
    return R;
}

// vector<ll> testFunc(vector<int> W, vector<int> A, vector<int> B, vector<int> E) {
//     int minBen = LLONG_MAX / 2;
//     int n = W.size();
//     ll res = 0;
//     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
//     res += minBen;
    
//     vector<ll> R(E.size(), res);
//     return R;
// }

Compilation message (stderr)

nile.cpp: In function 'std::vector<long long int> calculate_costs(std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
nile.cpp:50:45: error: no matching function for call to 'min(ll&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type)'
   50 |     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/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:
nile.cpp:50:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   50 |     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:60,
                 from nile.h:1,
                 from nile.cpp:1:
/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:
nile.cpp:50:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   50 |     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/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:
nile.cpp:50:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/vector:62,
                 from nile.h:1,
                 from nile.cpp:1:
/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:
nile.cpp:50:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   50 |     for (int i = 0; i < n; ++i) minBen = min(minBen, A[i] - B[i]), res += B[i];
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~