1746 - DS_2019_quiz0 Scoreboard

Time

2019/09/18 18:30:00 2019/09/18 19:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
12372 DS_2019Fall_OJ_test

12372 - DS_2019Fall_OJ_test   

Description

Problem: binary search

Given a sorted array and an integer value target.

Your task is to decide whether the target is in the array or not.

If the target exists, return its index, otherwise return -1.

 

There is no duplicated element in the array

If your choose C++, you can add ios_base::sync_with_stdio(false); to read input data faster 

 

Input

The first line contains an integer N, indicate the total number of testcases.

Each test case contains three lines

The ftirst line contains an integer, indicate the number of elements in the array. 

the second line is the sorted array.

The third line is the target.

1< N < 50

5 < number of element in the array < 1000000

Output

For each testcase, print the index of target if the target can be found in the array, otherwise print -1, followed by a newline symbol "\n"

Sample Input  Download

Sample Output  Download

Tags




Discuss