Problem:


Score : 200 points

Problem Statement

There is a kangaroo at coordinate 0 on an infinite number line that runs from left to right, at time 0.
During the period between time i-1 and time i, the kangaroo can either stay at his position, or perform a jump of length exactly i to the left or to the right.
That is, if his coordinate at time i-1 is x, he can be at coordinate x-i, x or x+i at time i.
The kangaroo's nest is at coordinate X, and he wants to travel to coordinate X as fast as possible.
Find the earliest possible time to reach coordinate X.

Constraints

X is an integer.

1≤X≤10^9

Input

The input is given from Standard Input in the following format:

X

Output

Print the earliest possible time for the kangaroo to reach coordinate X.

Sample Input 1

6

Sample Output 1

3

The kangaroo can reach his nest at time 3 by jumping to the right three times, which is the earliest possible time.

Sample Input 2

2

Sample Output 2

2

He can reach his nest at time 2 by staying at his position during the first second, and jumping to the right at the next second.

Sample Input 3

11

Sample Output 3

5



Sample input:
6


Sample output:
3

Submission status: Runtime Error

Solution code:
x=int(input())
n=int((2*int(input()))**0.5)
if n*(n-1)<2*x<=n*(n+1):
    print(n)
elif (n-1)*(n-2)<2*x<=n*(n-1):
    print(n-1)
else:
    print(n+1)

Submission status: Runtime Error

Solution code:
a = int(input())
i = 1
j = 0
ans = 0
while True:
	ans += 1
    j += i
    i += 1
    if j >= a:
      print(ans)
      break

Submission status: Runtime Error

Solution code:
X = int(input())
N = int(math.sqrt(2*X))-1

while True:
	if N*(N+1)//2 >= X:
		print(N)
		break
	N += 1

Submission status: Runtime Error

Solution code:
X = int(input())

for i in range(0, X):
    result += (i+1)
    if X >= result:
        print(i+1)
        break

Submission status: Runtime Error

Solution code:
X = int(input())

sumval = 0
for i in range(1,X):
	sumval += i
	if sumval >= X:
		ans = i
		break

print(ans)

Submission status: Runtime Error

Solution code:
from bisect import bisect_left, bisect_right, insort_left, insort_right


def solve():
    x = int(input())
    cumulative_sum = [(k * (k - 1)) // 2 for k in range(1, 46)]
    target = bisect_left(cumulative_sum, x)
    if x in cumulative_sum:
        print(cumulative_sum.index(x))
    else:
        print(target - 1 + (x - cumulative_sum[target]))


solve()

Submission status: Runtime Error

Solution code:
def f(n, l):
  sum = 0
  for i in range(1, n+1):
    sum += i
    if sum >= n:
      return i

print(f(n, l))

Submission status: Runtime Error

Solution code:
https://www.lifehacker.jp/2017/11/171127_kakei_17.html?utm_source=dlvr.it&utm_medium=twitter

Submission status: Runtime Error

Solution code:
    X = int(input())
     
    L = 0
    for t in range(1, X) :
        L += t
        if L >= X :
            print(t)
            break

Submission status: Runtime Error

Solution code:
X = int(input())

L = 0
for i in range(1, X) :
    L += i
    if L >= X :

Submission status: Runtime Error

Solution code:
num = int(input())
i = 1
while True:
    bef = range(1,i)
    i += 1
    aft = range(1,i)
    if bef < num <= aft:
        print(i-1)
        break

Submission status: Runtime Error

Solution code:
num = int(input())
i = 0
while True:
    bef = range(1,i)
    i += 1
    aft = range(1,i)
    if bef < num <= aft:
        print(i-1)
        break

Submission status: Runtime Error

Solution code:
import sys

X = int(input())

if X == 1:
	print(1)
elif X > 1:
	for i in range(2,1000000000):
		if X <= i*(i + 1)/2:
			t = i
			break
print(i)

Submission status: Runtime Error

Solution code:
import sys

X = int(input())

if X == 1:
	print(1)
elif X > 1:
	for i in range(2,100000):
		if X <= i*(i + 1)/2:
			t = i
			break
print(i)

Submission status: Runtime Error

Solution code:
X = int(raw_input())

def makeValue(x, n):
    if(n == 0):
        return False
    if(x == n):
        return True
    if(x == -n):
        return True
    if(makeValue(x - n, n - 1)):
        return True
    if(makeValue(x + n, n - 1)):
        return True

    return False

for i in range(1, X + 1):
    if(makeValue(X, i)):
        print i
        break

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

X= int(raw_input().split())

a = 0
while X >0:
    a += 1
    X -= a
print a

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-

X= map(int,raw_input().split())

a = 0
while X >0:
    a += 1
    X -= a
print a

Submission status: Runtime Error

Solution code:
y = [] 
x = 0

def slv(h, i):
    if x == h or i >= x:
        if x == h:
            y.append(i - 1)
        return
    slv(h+i, i+1)  # jump
    slv(h, i+1)  # stay

if __name__ == '__main__':
    x = abs(int(input()))
    slv(0, 0)

    if len(y) == 0:
        print(2)
    else:
        print(min(y))

Submission status: Runtime Error

Solution code:
y = []

def slv(x,h,i):
    if x == h or i >= x:
        if x == h:
            y.append(i)
        return
    slv(x,h+i,i+1) # jump
    slv(x,h,i+1) # stay

if __name__ == '__main__':
    x = int(input())
    slv(abs(x),0,0)

    if len(y) == 0:
        print(2)
    else:
        print(min(y) - 1)

Submission status: Runtime Error

Solution code:
y = []                                                                                                                  
                                                                                                                        
def slv(x,h,i):                                                                                                         
    if x == h or i >= x:                                                                                                
        if x == h:                                                                                                      
            y.append(i)                                                                                                 
        return                                                                                                          
    slv(x,h+i,i+1) # jump                                                                                               
    slv(x,h,i+1) # stay                                                                                                 
                                                                                                                        
if __name__ == '__main__':                                                                                              
    x = int(input())                                                                                                    
    slv(abs(x),0,0)                                                                                                     
                                                                                                                        
    print(y)                                                                                                            
                                                                                                                        
    if len(y) == 0:                                                                                                     
        print(2)                                                                                                        
    else:                                                                                                               
        print(min(y) - 1)

Submission status: Runtime Error

Solution code:
import math
X = int(input())
n = math.sqrt(2*X) -1

def sum(a):
    x = 0
    for i in range(a+1):
        x += i
    return x

for i in range(n,X+1):
    if sum(i)>= X:
        result = i
        break

print(result)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def check(t, n, idx):
    if t == n + idx or t == n - idx:
        return idx
    if idx >= t and t > 0:
        return t
    elif t < 0 and idx * -1 <= t:
        return idx
    return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))

X = int(input())
print(check(X, 0, 1))

Submission status: Runtime Error

Solution code:
# -*- coding:utf-8 -*-
def search(t, x, i):
#    print('t:'+str(t)+' x:'+str(x)+' i:'+str(i))
    global X
#    print(l)
#    print('X:'+str(X))
    if x == X:
        #l.append(t)
        return t
    elif x > X:
        ans1 = search(i, x, i+1)
        ans2 = search(i, x-i, i+1)
        return min(ans1, ans2)
    else:
        ans3 = search(i, x+i, i+1)
        return ans3


X = int(input())
ans = search(0, 0, 1)
print(ans)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def check(t, n, idx):
    if t == n + idx or t == n - idx:
        return idx
    if idx >= t:
        return t
    return min(check(t, n + idx, idx + 1), check(t, n - idx, idx + 1), check(t, n, idx + 1))

X = int(raw_input())
print(check(X, 0, 1))

Submission status: Runtime Error

Solution code:
x = int(raw_input())

ans = 0
count = 0
half = x / 2
array = range(x + 1)

for i in range(x):
    if x == 2 or x == 1:
        break

    if sum(array) == x:
        break
    elif sum(array[:len(array) - 2]) < x:
        array.pop()
        break
    else:
        array.pop()
    count += 1

print array[len(array) - 1]

Submission status: Runtime Error

Solution code:
x = int(raw_input())

ans = 0
count = 0

for i in range(x + 1):

    ans += i
    if ans >= x:
        count = i
        break

print count

Submission status: Runtime Error

Solution code:
import math
X = int(input())
l = list(range(1,math.ceil(X / 2)))
while l:
    if sum(l) < X:
        print(len(l)+1)
        break
    l.pop()

Submission status: Runtime Error

Solution code:
X = int(input())

def move(i, x):
 if x == X:
  return i
 elif i > X:
  return X+1
 else:
  if x > X:
   return min([move(i+1, x-(i+1)), move(i+1, x)])
  else:
   return min([move(i+1, x+(i+1)), move(i+1, x)])

print((move(0,0)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def check(t, now, idx):
    if t < idx:
        return 99999999999
    # use
    use = 999999999999
    if t == now + idx:
        use = idx
    elif t > now + idx:
        use = check(t, now + idx, idx + 1)
    # not use
    nuse = check(t, now, idx + 1)

    return min(use, nuse)

X = int(raw_input())
print(str(check(X, 0, 1)))

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
def check(t, now, idx):
    if t < idx:
        return 99999999999
    # use
    use = -1
    if t == now + idx:
        use = idx
    else:
        use = check(t, now + idx, idx + 1)
    # not use
    nuse = check(t, now, idx + 1)

    return min(use, nuse)

X = int(raw_input())
print(str(check(X, 0, 1)))

Submission status: Runtime Error

Solution code:
def move(i=0,cx=0):
    global m
    if(cx+i==X):
        m=min(m,i)
    elif cx+i<X:
        move(i+1,cx+i)
        move(i+1,cx)



X=int(input())
m=10**9
move()
print(m)