PersonalCorpus 版 (精华区)

152035 14:17:13 2 Mar 2002
Bozhang,HIT,P.R.China 1061 Pascal Accepted 0.04 sec 147K


var
    s:array[1..100000] of char;
    i,j,k,n,sum,res,bs:integer;
begin
    readln(n,k);
    i:=0;
    while i<n do begin
        inc(i); read(s[i]);
        if i mod 80=0 then readln;
    end;
    i:=1;j:=1; sum:=0; bs:=maxint; res:=0;
    while (j<=n) do begin
        if s[j]='*' then begin sum:=0; inc(j); i:=j; continue end;
        sum:=sum+ord(s[j])-48;
        inc(j);
        if j-i=k then begin
            if sum<bs then begin bs:=sum; res:=i end;
            sum:=sum-ord(s[i])+48;
            inc(i);
        end;
    end;
    writeln(res);
end.
[百宝箱] [返回首页] [上级目录] [根目录] [返回顶部] [刷新] [返回]
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:2.825毫秒