Submission #1251170

#TimeUsernameProblemLanguageResultExecution timeMemory
1251170lambd47쌀 창고 (IOI11_ricehub)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "ricehub.h"
using namespace std;

#define ll long long
#define L(i,j,k) for(int i=(j);i<=(k);i++)
#define R(i,j,k) for(int i=(j);i>=(k);i--)
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()


int besthub(int n, int troll, int vec[], long long B){

    int l,r;
    int med;
    ll val;
    auto ini=[&](int x)->void{
        l=0;
        r=x-1;
        med=vec[(l+r)/2];
        val=0;
        L(i,l,r)val+=abs(med-vec[i]);
    };
    auto upd=[&]()->void{
        val-=abs(vec[l]-med);
        l++;
        r++;
        int nmed=vec[(l+r)/2];
        val+=(nmed-med)*((l+r)/2-l);
        val-=(nmed-med)*(r-(l+r)/2);
        val+=abs(vec[r]-nmed);
        med=nmed;
    };
    auto testa=[&](int m)->bool{
        ini(m);
        int resp=val;
        while(r!=n-1){
            upd();
            resp=min(resp,val);
        }
        return resp<=B;
    };
    int lo=1, hi=n;

    int resp=1;
    while(lo<=hi){
        int m=(lo+hi)/2;
        if(testa(m)){
            lo=m+1;
            resp=m;
        }
        else hi=m-1;
    }
    return resp;



}

Compilation message (stderr)

ricehub.cpp: In lambda function:
ricehub.cpp:39:21: error: no matching function for call to 'min(int&, long long int&)'
   39 |             resp=min(resp,val);
      |                  ~~~^~~~~~~~~~
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 ricehub.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:
ricehub.cpp:39:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   39 |             resp=min(resp,val);
      |                  ~~~^~~~~~~~~~
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 ricehub.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:
ricehub.cpp:39:21: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   39 |             resp=min(resp,val);
      |                  ~~~^~~~~~~~~~
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 ricehub.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:
ricehub.cpp:39:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |             resp=min(resp,val);
      |                  ~~~^~~~~~~~~~
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 ricehub.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:
ricehub.cpp:39:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   39 |             resp=min(resp,val);
      |                  ~~~^~~~~~~~~~