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 1725. Sold Out!

i thin it's work correct, but can't get acc, please help!
Posted by wavejke 21 Jun 2011 16:03
where is my mistake? falls on 5th

var i,nr,n,k,c:integer;
begin
read(n,k);
nr:=trunc(n/2);
if (k>nr) then
begin
for i:=nr+1 to k-1 do
inc(c);
end;
if (k<nr) then
begin
for i:=k+1 to nr do
inc(c);
end;
write(c);
end.
Re: i thin it's work correct, but can't get acc, please help!
Posted by amirani 7 Aug 2012 15:24
Your code is very bad and solution is wrong too.
At first nr:=trunc(n/2) n is even because of this you could write nr=n div 2;
2.for i:=nr+1 to k-1 do
   inc(c); -----> this is very bad code.If you want something like that you should write
                c:=k-1-(nr+1)+1;
3.end here should be
    if (k > nr)
                Writeln(k -3)

            else
                WriteLn(n - k - 2);