top of page

소스 코드 제출

공개·회원 52명

atevtg3


# a = int(input())
# st = []
# wg = 0 # w(hat i lookin)g
# x = list(map(int,input().split()))
# for i in range(a):
#     if len(st)==0:
#         st.append([x[i],i])
#         print('0',end='')
#         continue
#     # print('\n asdfasdf',st[-1][0], st[-1][1], len(st), x[i])
#     while len(st)!=0 and x[i] >= st[-1][0]:
#         st.pop()
#     #print(st)
#
#     if len(st)!=0:
#         # print('asdfasdf2',st[-1][0],st[-1][1],i,x[i])
#         print('',st[-1][1]+1,end='')
#     else:
#         print(' 0',end='')
#     st.append([x[i],i])
a = int(input())
b = list(map(int,input().split()))
c = int(input())
d = list(map(int,input().split()))
import sys
sys.setrecursionlimit(354796868)
def bs(target,sp,ep):
    global b
    cPos = sp+((ep-sp)//2)
    if target == b[cPos]:
        return cPos + 1
    elif target < b[cPos]:
        bs(target,sp,cPos)
    else:
        bs(target,cPos,ep)
    if sp==ep:
        return -1

for i in range(c):
    print(bs(d[i],0,len(b)-1),end=' ')

1회 조회
주소 : 경기도 용인시 광교중앙로 302 블루 스퀘어 602호
연락처 : 031) 216 - 1546 ,     031) 215 - 1546
사업자등록번호 : 465-92-00916
​학원 등록 제 4603호
bottom of page