比赛 20121023 评测结果 AAAAAAAAAA
题目名称 圆圈舞蹈 最终得分 100
用户昵称 Rotide 运行时间 0.066 s
代码语言 Pascal 内存使用 0.93 MiB
提交时间 2012-10-23 21:11:05
显示代码纯文本
Var
    i,j,k,n,m,l,r,s,t,x,y,ans,sum:longint;
    a:array[1..201000]of longint;

Procedure Pin;
var
    i,j,k:longint;
begin
    read(n);
    sum:=0;
    for i:=1 to n do
        begin
            read(a[i]);
            a[i+n]:=a[i];
            sum:=sum+a[i];
        end;
end;


Procedure Main;
var
    i,j,k:longint;
begin
    r:=1;
    s:=a[1];
    for l:=1 to 2*n-1 do
        begin
            repeat
                r:=r+1;
                s:=s+a[r];
            until (s>sum/2)or(r=2*n-1);
            s:=s-a[r];
            dec(r);
            if (ans<s )and(s<=sum/2) then
                ans:=s;
            s:=s-a[l];
        end;
end;

begin
    assign(input,'circlea.in');
    assign(output,'circlea.out');
    reset(input); rewrite(output);
    pin;
    main;
    writeln(ans);
    close(input);
    close(output);
end.