Problem:
 Score: 200 points    Problem Statement A country decides to build a palace.  In this country, the average temperature of a point at an elevation of x meters is T-x \times 0.006 degrees Celsius.  There are N places proposed for the place. The elevation of Place i is H_i meters.  Among them, Princess Joisino orders you to select the place whose average temperature is the closest to A degrees Celsius, and build the palace there.  Print the index of the place where the palace should be built.  It is guaranteed that the solution is unique.      Constraints  1 \leq N \leq 1000  0 \leq T \leq 50  -60 \leq A \leq T  0 \leq H_i \leq 10^5  All values in input are integers.  The solution is unique.         Input Input is given from Standard Input in the following format:  N  T  A  H_1  H_2  ...  H_N       Output Print the index of the place where the palace should be built.        Sample Input 1 2
12 5
1000 2000      Sample Output 1 1   The average temperature of Place 1 is 12-1000 \times 0.006=6 degrees Celsius.  The average temperature of Place 2 is 12-2000 \times 0.006=0 degrees Celsius.   Thus, the palace should be built at Place 1 .       Sample Input 2 3
21 -11
81234 94124 52141      Sample Output 2 3

Solution (Python):


N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

idx = 0
for i in range(N):
    if(abs(A - (T - 0.006 * H[i])) < abs(A - (T - 0.006 * H[idx]))):
        idx = i

print(idx + 1)

Solution (Python):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

ans = -1
d = float('inf')
for i in range(n):
    b = abs(a - (t - 0.006 * h[i]))
    if b < d:
        d = b
        ans = i + 1

print(ans)

Solution (Python):
def abc113_b():
    import numpy as np
    n = int(input())
    t, a = map(int, input().split())
    h = np.array(list(map(int, input().split())))
    temp = np.abs(a - (t - h * 0.006))
    return np.argmin(temp) + 1


print(abc113_b())

Solution (Python):
N = int(input())
T, A = tuple(int(i) for i in input().split())
Hs = [int(i) for i in input().split()]

HT = [abs(T - h*0.006 - A) for h in Hs]
print(1 + HT.index(min(HT)))

Solution (Python):
n = int(input())
t,a =map(int,input().split())
h = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    b[i] = abs(a-(t-h[i]*0.006))
print(b.index(min(b))+1)

Solution (Python):
N = int(input())
T, A = [int(_) for _ in input().split()]
H = [abs(T - int(_) * 0.006 - A) for _ in input().split()]

mi = 0
for i in range(N):
    if H[mi] > H[i]:
        mi = i

print(mi + 1)

Solution (Python):
N = int(input())
T,A = map(int,input().split())
H = list(map(int,input().split()))
ans = 0
location = -1
for i in range(len(H)) :
    p = T-H[i]*0.006
    if i == 0 :
        ans = p
        location = 1
    else :
        if abs(A-ans) > abs(A-p) :
            ans = p
            location = 1+i
print(location)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = 100000000
for i in range(N):
    dif = abs(A - (T - H[i] * 0.006))
    if ans > dif:
        ans = dif
        spot = i+1
print(spot)

Solution (Python):
import bisect
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))

for i in range(n):
    h[i] = abs(t-h[i]*0.006-a)

k = h.index(min(h))

print(k+1)

Solution (Python):
N = int(input())
T, A = map(int, input().split())

T *= 1000
A *= 1000

max_diff = float('inf')
ans = 0
for i, h in enumerate(map(int, input().split()), 1):
    t = T - h * 6
    d = abs(t - A)
    if d < max_diff:
        max_diff = d
        ans = i
print(ans)

Solution (Python):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

temp = 10**6
index = 0
for i in range(n):
    if temp > abs(a - (t - h[i] * 0.006)):
        temp = abs(a - (t - h[i] * 0.006))
        index = i + 1

print(index)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]

def a(x):
    return T - x * 0.006

ans = 0
tmp = float('inf')
for i, v in enumerate(map(a, H)):
    i += 1
    if abs(v - A) < tmp:
        tmp = abs(v-A)
        ans = i
print(ans)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
ans = -10000000000
ansi = -1
for i, h in enumerate(H):
    t = T - 0.006*h
    if abs(t - A) < abs(ans - A):
        ans = t
        ansi = i
print(ansi + 1)

Solution (Python):
n = int(input())
t,a = map(int,raw_input().split(' '))
arr = map(int,raw_input().split(' '))
e = [t-i*0.006 for i in arr]
print e.index(min(e, key=lambda x:abs(x-a)))+1

Solution (Python):
a = int(input())

x,y = map(int,input().split())

l = list(map(int,input().split()))

c = []

for i in range(a):
    c.append(abs((x - (0.006 * l[i])) - y))

k = min(c)
kk = 0
for i in range(a):
    if k == c[i]:
        kk = i+1



print(kk)

Solution (Python):
N = int(input())
T, A = [int(i) for i in input().split()]
H = [int(i) for i in input().split()]
ans = -1
nearest = float('inf')
for k, h in enumerate(H, 1):
    tmp = abs(A - (T - 0.006 * h))
    if tmp < nearest:
        ans = k
        nearest = tmp
print(ans)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
T, A = T * 1000, A * 1000
rec = float("inf")
H = list(map(int, input().split()))
ans = -1
for i in range(N):
    t = T - H[i] * 6
    if rec > abs(A - t):
        ans = i + 1
        rec = abs(A - t)

print(ans)

Solution (Python):
import numpy as np

n = int(input())
[t, a] = list(map(int, input().split()))
h = list(map(int, input().split()))

h = np.abs((t - a) - 0.006 * np.array(h))
print(np.argsort(h)[0]+1)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))

minv = 1000000
for i, x in enumerate(H):
    tmp = T - x * 0.006
    if minv > abs(A-tmp):
        minv = abs(A-tmp)
        ans = i+1
print(ans)

Solution (Python):
n = int(input())
t, a = list(map(int, input().split()))
hs = list(map(int, input().split()))

min_diff = 100000
min_index = -1
for i, h in enumerate(hs):
    cut_t = t - h * 0.006
    if abs(cut_t - a) < min_diff:
        min_index = i
        min_diff = abs(cut_t - a)
print(min_index + 1)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
*H, = map(int, input().split())
ans = None; v = 10**18
for i, h in enumerate(H):
    w = abs(A*1000 - T*1000 + 6*h)
    if w < v:
        v = w
        ans = i
print(ans+1)

Solution (Python):
N = int(input())
T, A = map(int, input().split())

H = list( map(int, input().split()))

mindiff = 1e9
ans = -1

for i in range(N):
  if abs(T - 0.006*H[i] -A) < mindiff:
    mindiff = abs(T - 0.006*H[i] -A)
    ans = i+1
    
print(ans)

Solution (Python):
n = input()
t,a = map(int,raw_input().split())
arr = map(int,raw_input().split())
val = 10**20
ind = -1
for i in range(n):
	z = t-arr[i]*.006
	if abs(z-a) < val:
		ind = i+1
		val = abs(z-a)
print ind

Solution (Python):
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
print(min(enumerate(h), key=lambda x: abs(t-x[1]*0.006-a))[0]+1)

Solution (Python):
def getN():
    return int(input())


def getNM():
    return map(int, input().split())


def getList():
    return list(map(int, input().split()))

n =getN()
t, a = getNM()
high = getList()

diff = 100000000
for i, h in enumerate(high):
    temp = t - h*0.006
    if abs(temp-a) < diff:
        ans = i
        diff = abs(temp-a)


print(ans+1)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = [int(x) for x in input().split()]
TH = [[abs(T - H[i] * 0.006 - A), i] for i in range(N)]
TH.sort()
print(TH[0][1] + 1)

Solution (Python):

n = int(input())
t,a = map(int, input().split())
h = [int(x) for x in input().split()]

def temp(x):
    return t - x*0.006

ret = -1
diff = 10**5
for i in range(n):
    ht = temp(h[i])
    if abs(a-ht)<diff:
        diff = abs(a-ht)
        ret = i+1
print(ret)

Solution (Python):
n=int(input())
t,a=map(int,input().split())
data=list(map(int,input().split()))

new=[abs(t-0.006*data[i]-a) for i in range(n)]
print(new.index(min(new))+1)

Solution (Python):

def inpl(): return list(map(int, input().split()))
N = int(input())
T, A = inpl()
H = inpl()
good = 1e9
ans = 0
for i in range(N):
    temp = abs(A - (T - 0.006*H[i]))
    if good > temp:
        good = temp
        ans = i + 1

print(ans)

Solution (Python):
from fractions import Fraction

N = input()
T, A = map(int, raw_input().split())
H = map(int, raw_input().split())

v = float('inf')
x = -1

for i in xrange(N):
    vv = T - H[i] * Fraction(6, 1000)
    vvv = abs(A - vv)
    if vvv < v:
        v = vvv
        x = i

print x + 1

Solution (Python):


n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
ans = [(abs(t-h[i]*0.006-a), i) for i in range(len(h))]
print(sorted(ans)[0][1]+1)

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, T, A, H):

    tmp = []
    for i, h in enumerate(H):
        tmp.append((abs(A-(T-h*0.006)), i))
    return min(tmp)[1] + 1


def main():
    N = read_int()
    T, A = read_int_n()
    H = read_int_n()
    print(slv(N, T, A, H))


if __name__ == '__main__':
    main()

Solution (Python):
n = input()
t,a = map(float,raw_input().split())
l = map(float,raw_input().split())
ans = abs(t-0.006*l[0]-a)
index = 1
for i in xrange(1,n):
	x = abs(t-0.006*l[i]-a)
	if x < ans:
		ans = x
		index = i+1
print index

Solution (Python):
N=int(input())
T,A=map(int,input().split())
h = list(map(int,input().split()))
dist = 10**6
ans = -1
c = 0.006
for i in range(N):
    if abs(T-c*h[i]-A) < dist:
        dist = abs(T-c*h[i]-A)
        ans = i+1
print(ans)

Solution (Python):
n=int(input())
t,a=map(int,input().split())
arr=list(map(int,input().split()))
ans=10**18
ans1=-1
for i in range(len(arr)):
    val=t-(arr[i]*.006)
    if(abs(val-a)<ans):
        ans=abs(val-a)
        ans1=i
print(ans1+1)

Solution (Python):
N=int(input())
T,A=list(map(int,input().split()))
ans=0
min_=10**6
for i,h in enumerate(map(int,input().split())):
    if abs(T-h*0.006-A)<min_:
        min_=abs(T-h*0.006-A)
        ans=i+1
print(ans)

Solution (Python):
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
t,a = li()
h = list(li())

temp_list = []

for i in range(n):
    temp_list.append(t - h[i]*0.006)
 
ans = 10**18
for j, temp in enumerate(temp_list):
    if abs(a-temp) < ans:
        point = j
        ans = abs(a-temp)
        
print(point+1)

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
T, A = map(int, raw_input().split())
H = map(int, raw_input().split())

ans = 0
cost = INF
for i in range(N):
    if abs(T - H[i] * 0.006 - A) < cost:
        cost = abs(T - H[i] * 0.006 - A)
        ans = i + 1

print ans

Solution (Python):
n = int(input())
t, a = map(int, input().split())
ans, at = 0, float('inf')
for i, h in enumerate(map(int, input().split())):
    tt = abs(t - h * 0.006 - a)
    if at > tt:
        ans = i + 1
        at = tt
print(ans)

Solution (Python):
N = int(input())
T, A = map(int,input().split())
H = list(map(int,input().split()))
d = 100000
ans = 0
for k in range(N):
    if abs(A-T+H[k]*0.006) < d:
        d = abs(A-T+H[k]*0.006)
        ans = k+1

print(ans)

Solution (Python):
n = int(input())
t,a = (int(i) for i in input().split())
x = [t-int(i)*0.006 for i in input().split()]
m = float("inf")
for i in range(n):
	if m>abs(a-x[i]): m,k = abs(a-x[i]),i+1
print(k)

Solution (Python):
N = int(input())
T, A = [int(_) for _ in input().split()]
H = [int(_) for _ in input().split()]

result = 0
rd = 100000000000000000000000

for i, x in enumerate(H):
    t = T - 0.006 * x
    d = abs(A - t)
    if d < rd:
        rd = d
        result = i + 1

print(result)

Solution (Python):

N=int(input())
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))

min_dis = 10**9
ans = -1
for i in range(N):
    d = abs(A-(T-H[i]*0.006))
    if min_dis>d:
        ans=i+1
        min_dis = d

print(ans)

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = [int(i) for i in input().split()]
CT, Ans = float("inf"), 0
for i in range(N):
    Av = T - H[i] * 0.006
    if CT > abs(Av - A):
        CT, Ans = abs(Av-A), i
print(Ans+1)

Solution (Python):
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
temp = []
for i in h:
    temp.append(t - i*0.006)
m = float('inf')
ans = 0
for i,j in enumerate(temp):
    if m > abs(j-a):
        m = abs(j-a)
        ans = i
print(ans+1)

Solution (Python):
from sys import stdin
il = lambda func=int: list(map(func, stdin.readline().rstrip().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

n = int(input())
t, a = il()
h = il()
mint = 10000000
for cnt, i in enumerate(h):
    if abs(a- (t - i * 0.006)) < mint:
        mint = abs(a- (t - i * 0.006))
        ans = cnt+1
print(ans)

Solution (Python):
n = int(input())
t,a = map(int,input().split())
h = list(map(int,input().split()))
temp = 1000
ind = -1
for i in range(n):
    if abs(a-(t-0.006*h[i])) < temp:
        temp = abs(a-(t-0.006*h[i]))
        ind = i+1
print(ind)

Solution (Python):
N = input()
T,A = map(float, raw_input().split())
H = map(int, raw_input().split())
ans = 0
for i in range(1,N):
  if abs(T-H[i]*0.006-A)<abs(T-H[ans]*0.006-A):
    ans = i
print ans+1

Solution (Python):
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))

z = float('inf')
zi = -1
for i, hi in enumerate(h):
    ti = t - hi*0.006
    if abs(a-ti) < z:
        z = abs(a-ti)
        zi = i+1
print(zi)

Solution (Python):
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))

TEMP=[(abs((T-H[i]*0.006)-A),i+1) for i in range(N)]

print(min(TEMP)[1])

Solution (Python):
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
X = [abs(A - (T-h*0.006))for h in H]
print(X.index(min(X)) + 1)

Solution (Python):
N=int(input())
T,A=map(int,input().split())
H=[int(i) for i in input().split()]
S=[abs(A-(T-H[i]*0.006)) for i in range(N)]
res=min(S)
for i in range(N):
    if S[i]==res:
        print(i+1)

Solution (Python):
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
gap = float("inf")
for i in range(n):
	if abs(t - h[i] * 0.006 - a) < gap:
		ans = i + 1
		gap = abs(t - h[i] * 0.006 - a)
print(ans)

Solution (Python):
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))
x=[t-h[i]*0.006 for i in range(n)]
y=[abs(a-t) for t in x]
mi,mx=-1,1<<32
for i in range(n):
    if y[i]<mx:
        mx=y[i]
        mi=i
print(mi+1)

Solution (Python):
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()  

n = ni()
t, a = na()
h = na()

best = -99999999999
arg = -1
for i in range(n):
    tt = t - h[i]*0.006
    if abs(tt-a) < abs(best-a):
        best = tt
        arg = i+1
print(arg)