#include <bits/stdc++.h>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LLI long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Pos(i) cout<<(i?"Possible":"Impossible")<<endl
#define fcout cout<<fixed<<setprecision(10)
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int n,k,q;
int a[2000];

//最小値m以上,最大値M以下にできるか?
bool solve(int m,int M){
	int s=0,t=0;
	FOR(i,0,n){
		if(a[i]<m||a[i]>M){
			t+=max(0,s-k+1);
			s=0;
		}else{
			s++;
		}
	}
	t+=max(0,s-k+1);
	return t>=q;
}

こんな感じなのはわかるんだけど
int main(){
	cin>>n>>k>>q;
	int ans=INF;
	FOR(i,0,n){
		cin>>a[i];
	}
	int A,B;
	FOR(i,0,n){
		int st=0,en=INF;
		while(st+1<en){
			int mid=(st+en)/2;
			if(solve(a[i],mid)){
				en=mid;
			}else{
				st=mid;
			}
		}
		if(ans>st-a[i]){
			A=a[i];
			B=st;
			ans=st-a[i];
		}
		//ans=min(ans,st-a[i]);
	}
	cout<<ans<<endl;
	cout<<A<<" "<<B<<endl;
}
