QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#202264#6632. Minimize Medianarseny_y#Compile Error//C++232.2kb2023-10-05 21:11:362023-10-05 21:11:36

Judging History

你现在查看的是最新测评结果

  • [2023-10-05 21:11:36]
  • 评测
  • [2023-10-05 21:11:36]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(n);
    for (auto &i : a) {
        cin >> i;
    }
    sort(a.begin(), a.end());
    vector<int> b(m + 1);
    for (int i = 1; i <= m; ++i) {
        cin >> b[i];
    }
    vector<ll> dp(m * 4 + 1, LLONG_MAX);
    dp[1] = b[1];
    for (int i = 2; i <= m; ++i) {
        dp[i] = min(dp[i], 1LL * b[i]);
        for (int j = 2; j <= m && 1LL * i * j < (int)dp.size(); ++j) {
            dp[i * j] = min(dp[i * j], dp[i] + b[j]);
        }
    }
    for (int i = (int)dp.size() - 2; i >= 1; --i) {
        dp[i] = min(dp[i], dp[i + 1]);
    }
    int l = -1, r = m + 1;
    vector<ll> make0(m + 1, LLONG_MAX);
    for (int i = 1; i <= m; ++i) {
        make0[i] = dp[i + 1];
        for (int x = 1; 1LL * x * x <= 1LL * i; ++x) {
            int px = x;
            {
                int y = i / x - 1;
                while (1LL * x * y <= 1LL * i) ++y;
                make0[i] = min(make0[i], dp[x] + dp[y]);
            }
            {
                x = i / x;
                int y = i / x - 1;
                while (1LL * x * y <= 1LL * i) ++y;
                make0[i] = min(make0[i], dp[x] + dp[y]);
            }
            x = px;
        }
    }
    while (r - l > 1) {
        int mid = (l + r) / 2;
        if (mid == 0) {
            ll sm = 0;
            for (int i = 0; i <= n / 2; ++i) {
                sm += min(make0[a[i]], dp[a[i] + 1]);
                if (sm > k) break;
            }
            sm <= k ? r = mid : l = mid;
            continue;
        }
        auto na = a;
        int cnt = 0;
        ll sm = 0;
        for (int i = 0; cnt <= n / 2; ++i, ++cnt) {
            if (a[i] <= mid) continue;
            int x = max(2, a[i] / mid - 2);
            while (a[i] / x > mid) {
                ++x;
            }
            sm += min({make0[a[i]], dp[a[i] + 1], dp[x]});
            if (sm > k) break;
        }
        sm <= k ? r = mid : l = mid;
    }
    cout << r << '\n';
}

int32_t main(){
    cin.tie(nullptr)->sync_with_stdio(false);
    int t;
    cin >> t;
    while (t--) {
        solve();
    }
}

詳細信息

answer.code: In function ‘void solve()’:
answer.code:64:24: error: no matching function for call to ‘max(int, __gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type)’
   64 |             int x = max(2, a[i] / mid - 2);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
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 answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
answer.code:64:24: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’})
   64 |             int x = max(2, a[i] / mid - 2);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
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 answer.code:1:
/usr/include/c++/11/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++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
answer.code:64:24: note:   deduced conflicting types for parameter ‘const _Tp’ (‘int’ and ‘__gnu_cxx::__alloc_traits<std::allocator<long long int>, long long int>::value_type’ {aka ‘long long int’})
   64 |             int x = max(2, a[i] / mid - 2);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: ‘template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)’
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
answer.code:64:24: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   64 |             int x = max(2, a[i] / mid - 2);
      |                     ~~~^~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from answer.code:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: ‘template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)’
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
answer.code:64:24: note:   mismatched types ‘std::initializer_list<_Tp>’ and ‘int’
   64 |             int x = max(2, a[i] / mid - 2);
      |                     ~~~^~~~~~~~~~~~~~~~~~~