# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
208133 |
2020-03-10T04:58:09 Z |
YJU |
Watching (JOI13_watching) |
C++17 |
|
0 ms |
0 KB |
#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,0,sizeof(DP));
DP[0][0]=0;
REP(i,P+1)REP(j,Q+1){
DP[i][j+1]=max(DP[i][j+1],(ll)lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
DP[i+1][j]=max(DP[i+1][j],(ll)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
watching.cpp: In function 'bool b(ll)':
watching.cpp:27:70: error: invalid cast from type '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to type 'll {aka long long int}'
DP[i][j+1]=max(DP[i][j+1],(ll)lwb(v.begin(),v.end(),v[DP[i][j]]+2*k)-v.begin());
^
watching.cpp:28:70: error: invalid cast from type '__gnu_cxx::__normal_iterator<long long int*, std::vector<long long int> >' to type 'll {aka long long int}'
DP[i+1][j]=max(DP[i+1][j],(ll)lwb(v.begin(),v.end(),v[DP[i][j]]+1*k)-v.begin());
^