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!

Please help, WA on #5
Posted by Dragan Vidakovic 13 Jan 2010 02:48
I don't know where I made mistake,it falls on 5th example!!!


# include <iostream>
using namespace std;
int n,k,m,sol;
int main ()
{
    cin>>n>>k;
    m=n/2;
    if (k==m) sol=0;
    if (k<m) sol=m-k;
    if (k>m) sol=k-m-1;
    cout<<sol<<endl;
    system("pause");
}
Re: Please help, WA on #5
Posted by Berbinschi Tudor 7 Apr 2011 22:08
Mine too.
Re: Please help, WA on #5
Posted by wavejke 21 Jun 2011 15:57
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.