Can someone give me some testcases for which my code gives WA…
in the BOSSLOSS question of JULY LOC 2017…Here is the link to my Solution…
https://www.codechef.com/viewsolution/14698051
PS: I Applied Binary Search…and used long long int…too…I cant find any Wrong testcases.
The solution not visible. Can you give the ideone link.
The basic errors were -
Quadratic equations solution need not be integer. You have to round it appropriately (eg, if input is 5, then 3 shops are to be visited, but solving quadratic gives ans <3)
The data types used should be correct.
N is upto 10^18, make sure you didnt do n x n anywhere, because it will overflow. (in c++ etc)
You can cross check with my code:
import math
for _ in range(input()):
n,m = map(int,raw_input().split())
if n*(n+1)/2 < m :
print -1
else:
a,b,c = 1,1,-2*m
d = math.sqrt(1 - 4*a*c)
ans = int((-b+d)/2)
for i in range(max(ans-2,0),ans+2):
if i*(i+1)/2 >= m:
ans = i
break
print ans