fork(2) download
  1. const
  2. finp = '';
  3. fout = '';
  4. var
  5. fi,fo : text;
  6. n,res : integer;
  7. a : array[1..5000] of longint;
  8. f : array[0..5000,0..5000] of longint;
  9. //
  10. procedure ReadFile;
  11. var
  12. i : integer;
  13. begin
  14. assign(fi,finp);
  15. reset(fi);
  16. readln(fi,n);
  17. for i:=1 to n do
  18. read(fi,a[i]);
  19. close(fi);
  20. end;
  21. //
  22. procedure Process;
  23. var
  24. i,L : integer;
  25. begin
  26. res:=0;
  27. fillchar(f,sizeof(f),0);
  28. for i:=4 to n do
  29. for L:=2 to i-3 do
  30. if a[i-L]-a[i-L-1]=a[i]-a[i-1] then
  31. begin
  32. f[i,L]:=f[i-1,L]+1;
  33. if f[i,L]>L then f[i,L]:=L;
  34. If f[i,L]>res then res:=f[i,L];
  35. end;
  36. if res>=4 then res:=res+1
  37. else res:=0;
  38. writeln(res);
  39. end;
  40. //
  41. begin
  42. ReadFile;
  43. Process;
  44. end.
Success #stdin #stdout 0.08s 97920KB
stdin
30
25 27 30 34 39 45 52 60 69 79 69 60 52 45 39 34 30 26 22 18
82 78 74 70 66 67 64 60 65 80
stdout
5