https://online.codingblocks.com/player/28486/content/4706/5268
solved if(mid*x <= m+(n-mid)*y) was mistake.