@@ -0,0 +1,1032 @@
+import java.util.*;%0Aimport java.math.*;%0A%0Aclass Main%7B%0A  public static void main(String args%5B%5D)%7B%0A    Scanner scan=new Scanner(System.in);%0A    while(scan.hasNext())%7B%0A      int n = scan.nextInt();%0A      int k = scan.nextInt();%0A      if(n*k==0) return;%0A%0A      //0th~k-1st, make sum of them is 0%0A      //then look k-th num, record 0 - 0th + kth, compare 0 and new value%0A      //then look (k+1)th num, record (old value - 1st + (k+1)th), compare maxium value and new value%0A      int table%5B%5D=new int %5Bn%5D;%0A      for(int i=0;i%3Cn;i++)%7B%0A        table%5Bi%5D=scan.nextInt();%0A      %7D%0A      %0A      int res=0;%0A      int max=0;%0A      int imax=0;%0A      for(int i=k;i%3Cn;i++)%7B%0A        res=res+table%5Bi%5D-table%5Bi-k%5D;%0A        if(res%3Emax)%7B%0A          //System.out.printf(%22max changed,imax=%25d,imaxEnd=%25d%5Cn%22,i-k+1,i);%0A          max=res;%0A          imax=i-k+1;%0A        %7D%0A      %7D%0A      %0A      long out=0;%0A      for(int i=imax;i%3Cimax+k;i++)%7B%0A        out+=table%5Bi%5D;%0A      %7D%0A      //System.out.printf(%22imax:%25d%5Cn%22,imax);%0A      System.out.println(out);%0A%0A    %7D%0A  %7D//main%0A%7D%0A

add 0516aoj.java