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 wrong answer?
Posted by Олег 19 Apr 2012 21:21
program demokratiya;
const max=9999;
var k,i,j,N:integer;
    p: array [1..max] of integer;
    x,sum:integer;
begin
   readln(k);
   N:=0;
  if (k<=101) and (k>=1) then
   begin
  for i:=1 to k do
   begin
    readln(p[i]);
    if (p[i] mod 2 = 0) or (p[i]>9999) then
     exit;
     N:=N+p[i];
   end;
   if N>9999 then exit;
   for i:=1 to k-1 do
     for j:=i downto 1 do
      begin
       if p[j]>p[j+1]
        then
         begin
          x:=p[j];
          p[j]:=p[j+1];
          p[j+1]:=x;
         end;
      end;
      k:=trunc(k/2)+1;
    for i:=1 to k do
     begin
         p[i]:=trunc(p[i]/2)+1;
         writeln(p[i],' ');
         sum:=sum+p[i];
    end;
         writeln(sum,'  ');
    end;
end.