Cod sursa(job #844561)

Utilizator RusuAlexeiRusu Alexei RusuAlexei Data 29 decembrie 2012 15:13:42
Problema Arbori de intervale Scor 40
Compilator fpc Status done
Runda Arhiva educationala Marime 0.72 kb
program arbori_de_intervale;
  var f1,f2:text;
      n,m,i,j,b,c,max:longint;
      a:array [1..100000] of longint;
      op:byte;
      bufin,bufout:array [1..100000] of byte;
begin
  assign(f1,'arbint.in');
  reset(f1);
  assign(f2,'arbint.out');
  rewrite(f2);
  settextbuf(f1,bufin);
  settextbuf(f2,bufout);
  readln(f1,n,m);
  for i:=1 to n do read(f1,a[i]); readln(f1);
  for i:=1 to m do
    begin
      readln(f1,op,b,c);
      if op=0 then
                begin
                  max:=a[b];
                  for j:= b+1 to c do
                    if a[j]>max then max:=a[j];
                  writeln(f2,max);
                end
              else a[b]:=c;
    end;
  close(f1);
  close(f2);
end.