language: Pascal (gpc) (gpc 20070904)
date: 104 days 16 hours ago
link:
visibility: public
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
program diafora(input, output);
var N, i, j, temp, thesi, min : integer;
    a : array[1..1000000] of integer;
 
begin
 readln(N);
 thesi:= 0;
 i:= 0;
 while i < N do
 begin
  i:= i + 1;
  read(a[i]);
  if a[i] > 0 then thesi:= i
 end;
 readln;
 if thesi = 1 then writeln(a[1] + a[2])
 else if thesi = 0 then writeln(a[N - 1] + a[N])
 else
 begin
  if thesi < N then min:= a[thesi] + a[thesi + 1];
  if thesi > 2 then temp:= -(a[thesi - 1] + a[thesi - 2]);
  if temp < min then min:= temp;
  i:= 0;
  j:= thesi - 1;
  while i < thesi - 2 do
  begin
   i:= i + 1;
   while j < N do
   begin
    j:= j + 1;
    temp:= a[i] + a[j];
    if abs(temp) < abs(min) then min:= temp
   end
  end;
  writeln(min)
 end
end.
  • upload with new input
  • result: Runtime error     time: 0.02s    memory: 8020 kB     signal: -1

    ./prog: attempt to read past end of Input (error #454 at 804a0cf)