fork download
  1. program result;
  2.  
  3. const
  4. MAXN = 100000;
  5.  
  6. var
  7. N, i, h, count : LongInt;
  8. P, R : Array[0..MAXN-1] of LongInt;
  9. correttore : char;
  10. begin
  11. {
  12.   uncomment the two 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.  
  19. for i:=0 to N-1 do
  20. Read(R[i]);
  21. ReadLn();
  22.  
  23. for i := 0 to N-1 do P[i] := 0;
  24.  
  25. h:=1; count:=0;
  26. while h<N do
  27. begin
  28. if R[h]=h+1 then h:=h+1
  29. else
  30. begin
  31. if R[h]=R[h-1] then begin count:=count+1; h:=h+1; end
  32. else begin if R[h+1]=h+1 then correttore:='J'
  33. else correttore:='F';
  34. end;
  35. end;
  36. end;
  37. for i:=0 to N-1 do
  38. Write(P[i], ' ');
  39. WriteLn();
  40.  
  41. end.
Success #stdin #stdout 0s 5296KB
stdin
10
1 1 1 4 4 6 7 8 8 10
stdout
0 0 0 0 0 0 0 0 0 0