#include<stdio.h> #include<bits/stdc++.h> #define H 100005 using namespace std; struct node{int v,id;}Sum[H]; int N,T,P; bool cmp(node a,node b){ if(a.v==b.v)return a.id<b.id; return a.v>b.v; } void Work(){ int L,R,ans,Cha; L=R=Cha=1234567890; deque<int>Q; for(int i=0;i<=N;i++){ // while(!Q.empty()&&Sum[Q.front()].v-Sum[i].v>=P){ int k=Q.front(); int A=min(Sum[k].id,Sum[i].id); int B=max(Sum[k].id,Sum[i].id); int C=Sum[k].v-Sum[i].v; if(C-P<=Cha){ if(C-P==Cha){ if(A==L)R=min(R,B); IF the else (A <L) A = L, B = R & lt; } the else ANS = C, A = L, B = R & lt; Cha = the CP; } Q.pop_front (); } // discussion of the difference is greater than equal to P where Q .push_back (I); IF (Q.size () =. 1!) { int Q.front K = (); int = A min (the Sum [K] .id, the Sum [I] .id); int = B max (the Sum [K] .id, the Sum [I] .id); int the Sum C = [K] .v-the Sum [I] .v; IF (the PC <= Cha) { IF (the PC == Cha) { IF (A == L) R & lt = min (R & lt, B); the else IF (A <L) A = L, B = R & lt; } the else ANS = C, A = L, B = R & lt; Cha = the PC; } } // discussion of the difference is less than equal to P } the printf ( "% D% D% D \ n-", ANS,. 1 + L, R & lt); } int main () { Scanf ( "% D% D", N & , & T); for (int I =. 1; I <= N;i++){ X int; Scanf ( "% D", & X); the Sum [I] .v = the Sum [-I. 1] .v + X; the Sum [I] .id = I; } sort (Sum, Sum + 1 + N, cmp); // constant array from [0, N] to sort, since the situation will be a continuum from [1, i] of the while (T -) { Scanf ( " D% ", & P); Work (); } }