Page 103 - C:\Users\Admin\Desktop\Sach mem upweb\
P. 103

100 Problems & Solutions                                               Trang 103


                      Procedure chat(Var ok:boolean);
                      Var i:word;
                      Begin
                         Fillchar(d,sizeof(d),0);
                         Repeat
                            phan(ok);
                         Until not ok;
                         ok:=true;
                         for i:= n downto 1 do
                         if d[i]=0 then
                         Begin
                            ok:=false;
                            break;
                         End;
                      End;

                      Procedure Tinh;
                      Begin
                         For p:=gtmax to s div 2 do
                         Begin
                           chat(ok);
                           if ok then
                           Begin
                             writeln(fo,p);
                             break;
                           End;
                         End;
                         If not ok then
                         Writeln(fo,s);
                      End;

                      Procedure Start;
                      Var i:word;
                      Begin
                         assign(fi,'input.txt');reset(fi);
                         assign(fo,'output.txt');rewrite(fo);
                         While not seekeof(fi) do
                         Begin
                           Readln(fi,n);
                           if n<>0 then
                           Begin
                              gtmax:=0;s:=0;
                              for i:=1 to n do
                              Begin
                                 Read(fi,a[i]);
                                 s:=s+a[i];
                                 if a[i]> gtmax then
                                 gtmax:=a[i];
                              End;
                              Q_sort(1,n);
                              Tinh;
                           End;
                         End;
                         Close(fi);Close(fo);
                      End;

                      Begin
                         Start;
                      End.




                      Tin học & Nhà trường                                       100 Đề Toán - Tin học
   98   99   100   101   102   103   104   105   106   107   108