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

why it is wrong????????????
Posted by Aulterman 2 May 2004 08:28
var
  a,b:array [1..101] of longint;
  k:longint;
procedure init;
  var
    i:longint;
  begin
    fillchar(a,sizeof(a),0);
    readln(k);
    for i:=1 to k do
       read(a[i]);
  end;
procedure work;
  var
    k1,t,max,i,j,min,jl:longint;
  begin
    k1:=0;
    max:=0;
    min:=a[1];
    k1:=trunc(k/2)+1;
    for i:=1 to k-1 do
      for j:=1 to k-1 do
        begin
          if min>a[j+1] then begin min:=a[j+1]; jl:=j+1; end;
          if j=k-1 then begin b[i]:=min; a[jl]:=10002; min:=a[i]; end;
        end;
        for i:=1 to k1 do
        max:=max+(trunc(b[i]/2)+1);
     writeln(max);
  end;
begin
  init;
  work;
end.
Re: why it is wrong????????????
Posted by marina_ufa 3 May 2004 22:09
try test:

6
1 5 9 3 7 11

answer: 10

Why you not sort array???
Re: why it is wrong????????????
Posted by marina_ufa 4 May 2004 09:55
Sory? but my test is incorrect...
try this test

5
3 5 7 9 11

answer: 9