Codeforces Global Round 5 D. Balanced Playlist(单调队列)
题目链接#includeusingnamespacestd;constintmaxn=3e5+1;intn,a[maxn],q[maxn],ans[maxn],vis[maxn],maxx=0,minn=1e9+100;intmain(){scanf("%d",&n);for(inti=1;ia[i]*2)//从前往后遍历队列内的元素ans[vis[now]]=i-vis[now],now++;}