#include <bits/stdc++.h>
using namespace std;
deque<pair<int,int>>maxn;
deque<pair<int,int>>minn;
int n,m,c,a[500005],flag;
int main()
{
scanf("%d%d%d",&n,&m,&c);
for(int i=1;i<=n;i++) scanf("%d",&a[i]);
for(int i=1;i<m;i++)
{
while(!minn.empty() and maxn.back().second<a[i]) maxn.pop_back();
maxn.push_back({i,a[i]});
while(!minn.empty() and minn.back().second>a[i]) minn.pop_back();
minn.push_back({i,a[i]});
}
for(int l=1,r=m;r<=n;l++,r++)
{
if(!maxn.empty() and maxn.front().first<l) maxn.pop_front();
if(!minn.empty() and minn.front().first<l) minn.pop_front();
while(!maxn.empty() and maxn.back().second<a[r]) maxn.pop_back();
maxn.push_back({r,a[r]});
while(!minn.empty() and minn.back().second>a[r]) minn.pop_back();
minn.push_back({r,a[r]});
if((maxn.front().second-minn.front().second)<=c)
{
printf("%d\n",l);
flag=true;
}
}
if(flag==false) printf("NONE");
return 0;
}
https://www.luogu.com.cn/record/105755613