ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1025. Democracy in Danger

what is wrong in my code (WA №2)?
Posted by Alexandr Zhelanov 23 Nov 2012 00:22
What is wrong in my code? Please, give me a hint.

var
   k,i,min,max,voices,sum:integer;
   ka:array [1..101] of integer;
begin
     readln(k);
     for i:= 1 to k do
     begin
          read(ka[i]);
          if i=1 then
          begin
               min:=ka[i];
               max:=ka[i];
          end
          else
          begin
               if ka[i]<min then min:=ka[i];
               if ka[i]>max then max:=ka[i];
          end;
     end;

     if min<>max then
     begin
          for i:=1 to k do
          begin
               if ka[i]=min then
               sum:=sum+ka[i];
          end;
          voices:=sum div 2 +1;
     end
     else
     begin
          for i:=1 to k do
          sum:=sum+ka[i];

          voices:=sum div 2 +1;
     end;

     writeln(voices);
end.
Re: what is wrong in my code (WA №2)?
Posted by Bogatyr 24 Nov 2012 04:26
Try this test:

3
1 3 9995
Re: what is wrong in my code (WA №2)?
Posted by Alexandr Zhelanov 25 Nov 2012 15:34
answer : 3?
Re: what is wrong in my code (WA №2)?
Posted by Ivan Metelev UFU SESC 29 Oct 2014 14:42
Yes