#include using namespace std; typedef signed long long ll; #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define FORR2(x,y,arr) for(auto& [x,y]:arr) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) template bool chmax(T &a, const T &b) { if(a bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;} //------------------------------------------------------- int N,K,L; int A[5525]; int dp[5525][5525]; template class BIT_2d { public: V val[1<0;i-=i&-i) for(int j=y+1;j>0;j-=j&-j) s+=val[i-1][j-1]; return s; } void update(int x,int y,V v) { for(int i=x+1;i<=1< bit; int R[5525]; int ret[2525][2525]; vector> cand[2525]; int get(int L,int R) { return bit.total(R+1,R+1)-bit.total(R+1,L)-bit.total(L,R+1)+bit.total(L,L); } void solve() { int i,j,k,l,r,x,y; string s; cin>>N>>K>>L; FOR(i,N) cin>>A[i]; MINUS(dp); FOR(x,N) { R[x]=N; multiset S; for(y=x;yK) S.erase(S.find(*S.rbegin())); if(S.size()==K) { dp[x][y]=*S.rbegin(); cand[dp[x][y]].push_back({x,y}); } } } for(x=1;x<=N;x++) { FORR2(l,r,cand[x]) bit.update(l+1,r+1,1); FOR(i,N) { while(get(i,R[i]-1)>=L) { R[i]--; ret[i][R[i]]=x; } } } /* FOR(x,N) { for(y=x;y>Q; while(Q--) { cin>>x>>y; cout<