LoginSignup
0
0

More than 1 year has passed since last update.

Atcoder B - Palace

Last updated at Posted at 2022-05-05

問題

回答

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

ans = 1
dis = 0
list = []

for i in range(N): #それぞれの地点からの差分を計算する。
  dis = abs(T - H[i] * 0.006- A) 
  list.append(dis) #配列に格納。
  ans = list.index(min(list))+1 #配列の中で一番小さいindexに、1を足したものが答え。一番小さい値の順番に1を足した数が答えとなっている。

print(ans)

ポイント

個人的にはans = list.index(min(list))+1の部分。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0