fork download
  1. program ladder;
  2. Uses Math;
  3. const
  4. MAXN = 1000000;
  5.  
  6. var
  7. N, i, diff : longint;
  8. C : array[0..MAXN-1] of longint;
  9.  
  10. begin
  11. {
  12.   uncomment the following lines if you want to read/write from files
  13.   assign(input, 'input.txt'); reset(input);
  14.   assign(output, 'output.txt'); rewrite(output);
  15. }
  16.  
  17. readln(N);
  18. for i:=0 to N-1 do
  19. read(C[i]);
  20. readln();
  21. diff:=C[0];
  22. for i:=1 to N-1 do
  23. if C[i+1]>C[i] then diff:=max(diff, C[i+1-C[i]]);
  24. writeln(diff); { print result }
  25. end.
  26.  
Success #stdin #stdout 0s 5268KB
stdin
4
4 2 2 5

stdout
4