Submission #208131

#TimeUsernameProblemLanguageResultExecution timeMemory
208131YJUWatching (JOI13_watching)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll,ll> pll; typedef long double ld; const ll MOD=1e9+7; const ll N=2e3+5; const ld pi=3.14159265359; const ll INF=(1LL<<62); #define REP(i,n) for(ll i=0;i<n;i++) #define REP1(i,n) for(ll i=1;i<=n;i++) #define pb push_back #define mp make_pair #define X first #define Y second #define setp setprecision #define lwb lower_bound #define SZ(a) (ll)a.size() ll n,P,Q,x,DP[N][N]; vector<ll> v; bool b(ll k){ memset(DP,-1,sizeof(DP)); DP[0][0]=0; REP(i,P+1)REP(j,Q+1){ DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin()); DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin()); if(DP[i][j]==n)return 1; } return 0; } int main(){ ios_base::sync_with_stdio(0);cin.tie(0); cin>>n>>P>>Q; P=min(P,n);Q=min(Q,n); REP(i,n)cin>>x,v.pb(x); sort(v.begin(),v.end()); ll l=-1,r=MOD; while(r-l>1){ (b((r+l)/2)?r=(r+l)/2:l=(r+l)/2); } cout<<r<<"\n"; return 0; }

Compilation message (stderr)

watching.cpp: In function 'bool b(ll)':
watching.cpp:27:77: error: no matching function for call to 'max(ll&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
watching.cpp:27:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type {aka long int}')
   DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
watching.cpp:27:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type {aka long int}')
   DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
watching.cpp:27:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
watching.cpp:27:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   DP[i][j+1]=max(DP[i][j+1],lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
                                                                             ^
watching.cpp:28:77: error: no matching function for call to 'max(ll&, __gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type)'
   DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
watching.cpp:28:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type {aka long int}')
   DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/bits/specfun.h:45:0,
                 from /usr/include/c++/7/cmath:1914,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:41,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
watching.cpp:28:77: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >::difference_type {aka long int}')
   DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
watching.cpp:28:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
                                                                             ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from watching.cpp:1:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
watching.cpp:28:77: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   DP[i+1][j]=max(DP[i+1][j],lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
                                                                             ^