Cod sursa(job #775309)
| Utilizator | Data | 7 august 2012 19:32:32 | |
|---|---|---|---|
| Problema | Buline | Scor | 30 |
| Compilator | fpc | Status | done |
| Runda | Arhiva de probleme | Marime | 0.51 kb |
var a:array[1..399999]of integer; s,p,l,n,se,i,j:longint;
begin
assign(input,'buline.in'); reset(input);
readln(n);
for i:=1 to n do begin readln(a[i],se); if se=0 then a[i]:=-a[i] end;
for i:=(n+1) to ((2*n)-1) do a[i]:=a[i-n];
s:=0; l:=0;p:=0;
for i:=1 to n do
begin
se:=0;
for j:=i to (i+n-1) do
begin
se:=se+a[j];
if se>s then begin s:=se; p:=i; l:=j-i+1; end;
end;
end;
assign(output,'buline.out'); rewrite(output);
write(s,' ',p,' ',l);
close(output);
end.