Search is not available for this dataset
name
stringlengths 2
88
| description
stringlengths 31
8.62k
| public_tests
dict | private_tests
dict | solution_type
stringclasses 2
values | programming_language
stringclasses 5
values | solution
stringlengths 1
983k
|
|---|---|---|---|---|---|---|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
n = int(input().strip())
printing = []
for test in range(n):
m = input()
a = input().strip().split(" ")
b= []
for c in a:
b.append(int(c))
b.sort()
if int(b[0]) + int(b[1]) <= int(b[-1]):
d = []
d.append(a.index(str(b[0]))+1)
d.append(a.index(str(b[1]))+1)
count = 0
while d[1] == d[0]:
a[int(d[0])-1]=-1
d[1] = a.index(str(b[1]))+1
d.append(a.index(str(b[-1]))+1)
d.sort()
printing.append(" ".join(map(str,d)))
else:
printing.append("-1")
for item in printing:
print(item)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for i in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
if l[0]+l[1]<=l[n-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
def solve(n, a):
if a[0] + a[1] <= a[-1]:
print(1, 2, n)
return
else:
print(-1)
return
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
solve(n, a)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for _ in range(t):
flag=0
n=int(input())
inp=list(map(int,input().split()))
if inp[0]+inp[1]<=inp[-1]:
print (1,end=" ")
print (2,end=" ")
print (len(inp))
continue
else:
print (-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
input=sys.stdin.buffer.readline
inin=lambda: int(input())
inar=lambda: list(map(int,input().split()))
inst=lambda: input().decode().rstrip('\n\r')
INF=float('inf')
#from collections import deque as que, defaultdict as vector, Counter
#from bisect import bisect as bsearch
#from heapq import heapify, heappush as hpush, heappop as hpop
'''from types import GeneratorType
def recursive(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack:
break
to = stack[-1].send(to)
return to
return wrappedfunc'''
_T_=inin()
for _t_ in range(_T_):
n=inin()
a=inar()
if a[0]+a[1]>a[n-1]:
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
### START FAST IO ###
import os
os_input = os.read(0, int(1e7)).split()
os_input_pos = -1
answer_list = []
def read_s():
global os_input_pos
os_input_pos += 1
return os_input[os_input_pos].decode()
def read_i():
return int(read_s())
def write_s(v):
answer_list.append(v)
def write_i(v):
write_s(str(v))
def print_ans():
os.write(1, "\n".join(answer_list).encode())
os.write(1, "\n".encode())
#### END FAST IO ####
### START ITERATE RECURSION ###
from types import GeneratorType
def iterative(f, stack=[]):
def wrapped_func(*args, **kwargs):
if stack: return f(*args, **kwargs)
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack: break
to = stack[-1].send(to)
return to
return wrapped_func
#### END ITERATE RECURSION ####
T = read_i()
while T:
T -= 1
n = read_i()
a = sorted([(read_i(), i+1) for i in range(n)])
if a[0][0] + a[1][0] > a[-1][0]:
write_i(-1)
else:
ans = sorted([a[0][1], a[1][1], a[-1][1]])
write_s(" ".join([str(x) for x in ans]))
print_ans()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
#Consistency is the key.
#code by: amrit00
from sys import stdin,stdout
import math
input=stdin.readline
def print(*args,end='\n'):
s=[]
for i in args:
s.append(str(i)+' ')
s=''.join(s)
stdout.write(s+end)
def solve():
n=int(input())
l=list(map(int,input().split()))
if l[0]+l[1]<=l[-1]:
print(1,2,n)
else:
print(-1)
tt=1
tt=int(input())
for __ in range(tt):
solve()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
while t:
t -= 1
n = int(input())
arr = list(map(int,input().split()))
i = 0
# for i in range(n-2):
if arr[i]+arr[i+1]<= arr[n-1]:
print(i+1,i+2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.Arrays;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for (int f = 0; f < t; f++) {
int n = in.nextInt();
int a = in.nextInt();
int b = in.nextInt();
for (int i = 2; i < n-1; i++)
in.nextInt();
int c = in.nextInt();
if(a+b<=c)
System.out.println("1 2 " + n);
else
System.out.println(-1);
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def solve():
n=int(input())
arr=[int(i) for i in input().split()]
arr.sort()
if(arr[0]+arr[1]<=arr[-1]):
print(1,2,n)
return
print(-1)
test=int(input())
while test:
solve()
test-=1
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
mi, mi_idx, ma, ma_idx = 10**10, 0, 0, 0
for i in range(n):
if a[i] < mi:
mi, mi_idx = a[i], i
if a[i] > ma:
ma, ma_idx = a[i], i
ans = [mi_idx+1, ma_idx+1]
for i in range(n):
if i == mi_idx or i == ma_idx:
continue
if not(mi-ma < a[i] < mi+ma and mi-a[i] < ma < mi+a[i] and ma-a[i] < mi < ma+a[i]):
ans.append(i+1)
break
if len(ans) == 2:
print(-1)
else:
print(*sorted(ans))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.*;
import java.io.*;
import java.math.*;
public class practice {
InputStream is;
PrintWriter out;
static long mod=pow(10,9)+7;
int dx[]= {0,0,1,-1},dy[]={+1,-1,0,0};
void solve()
{
int t = ni();
outer:while(t--!=0) {
int n = ni();
int a[]=na(n);
mergeSort(a,0,n-1);
if(a[0]+a[1] > a[n-1]) {
out.println(-1);
continue outer;
}
ArrayList<Integer> index = new ArrayList<Integer>();
for(int i=0;i<n;i++) {
if(a[i]==a[0]) {
index.add(i);
a[i] = -1;
break;
}
}
for(int i=0;i<n;i++) {
if(a[i]==a[1]) {
index.add(i);
a[i] = -1;
break;
}
}
for(int i=0;i<n;i++) {
if(a[i]==a[n-1]) {
index.add(i);
a[i] = -1;
break;
}
}
Collections.sort(index);
for(int i=0;i<3;i++)
out.print(index.get(i)+1 +" ");
out.println();
}
}
int countDigits(int n) {
int ans=0;
while(n!=0) {
ans+=n%10;
n/=10;
}
return ans;
}
public static int bsdown(int a[],int item)
{
int low=0,high=a.length-1,ans=-1;
while(low<=high)
{
int mid=low+(high-low)/2;
if(a[mid]<=item)
{
ans=mid;
low=mid+1;
}
else
high=mid-1;
}
return ans;
}
ArrayList<Integer>al [];
void take(int n,int m)
{
al=new ArrayList[n];
for(int i=0;i<n;i++)
al[i]=new ArrayList<Integer>();
for(int i=0;i<m;i++)
{
int x=ni()-1;
int y=ni()-1;
al[x].add(y);
al[y].add(x);
}
}
int arr[][];
int small[];
void pre(int n)
{
small=new int[n+1];
for(int i=2;i*i<=n;i++)
{
for(int j=i;j*i<=n;j++)
{
if(small[i*j]==0)
small[i*j]=i;
}
}
for(int i=0;i<=n;i++)
{
if(small[i]==0)
small[i]=i;
}
}
public static int count(int x)
{
int num=0;
while(x!=0)
{
x=x&(x-1);
num++;
}
return num;
}
static long d, x, y;
void extendedEuclid(long A, long B) {
if(B == 0) {
d = A;
x = 1;
y = 0;
}
else {
extendedEuclid(B, A%B);
long temp = x;
x = y;
y = temp - (A/B)*y;
}
}
long modInverse(long A,long M) //A and M are coprime
{
extendedEuclid(A,M);
return (x%M+M)%M; //x may be negative
}
public static void mergeSort(int[] arr, int l ,int r){
if((r-l)>=1){
int mid = (l+r)/2;
mergeSort(arr,l,mid);
mergeSort(arr,mid+1,r);
merge(arr,l,r,mid);
}
}
public static void merge(int arr[], int l, int r, int mid){
int n1 = (mid-l+1), n2 = (r-mid);
int left[] = new int[n1];
int right[] = new int[n2];
for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
int i =0, j =0, k = l;
while(i<n1 && j<n2){
if(left[i]>right[j]){
arr[k++] = right[j++];
}
else{
arr[k++] = left[i++];
}
}
while(i<n1) arr[k++] = left[i++];
while(j<n2) arr[k++] = right[j++];
}
public static void mergeSort(long[] arr, int l ,int r){
if((r-l)>=1){
int mid = (l+r)/2;
mergeSort(arr,l,mid);
mergeSort(arr,mid+1,r);
merge(arr,l,r,mid);
}
}
public static void merge(long arr[], int l, int r, int mid){
int n1 = (mid-l+1), n2 = (r-mid);
long left[] = new long[n1];
long right[] = new long[n2];
for(int i =0 ;i<n1;i++) left[i] = arr[l+i];
for(int i =0 ;i<n2;i++) right[i] = arr[mid+1+i];
int i =0, j =0, k = l;
while(i<n1 && j<n2){
if(left[i]>right[j]){
arr[k++] = right[j++];
}
else{
arr[k++] = left[i++];
}
}
while(i<n1) arr[k++] = left[i++];
while(j<n2) arr[k++] = right[j++];
}
static class Pair implements Comparable<Pair>{
int x;
int y,k,i;
Pair (int x,int y){
this.x=x;
this.y=y;
}
public int compareTo(Pair o) {
if(this.x!=o.x)
return o.x-this.x;
return this.y-o.y;
}
public boolean equals(Object o) {
if (o instanceof Pair) {
Pair p = (Pair)o;
return p.x == x && p.y == y;
}
return false;
}
public int hashCode() {
return new Long(x).hashCode()*31 + new Long(y).hashCode() ;
}
@Override
public String toString() {
return "("+x + " " + y +" "+k+" "+i+" )";
}
}
public static boolean isPal(String s){
for(int i=0, j=s.length()-1;i<=j;i++,j--){
if(s.charAt(i)!=s.charAt(j)) return false;
}
return true;
}
public static String rev(String s){
StringBuilder sb=new StringBuilder(s);
sb.reverse();
return sb.toString();
}
public static long gcd(long x,long y){
if(x%y==0)
return y;
else
return gcd(y,x%y);
}
public static int gcd(int x,int y){
if(y==0)
return x;
return gcd(y,x%y);
}
public static long gcdExtended(long a,long b,long[] x){
if(a==0){
x[0]=0;
x[1]=1;
return b;
}
long[] y=new long[2];
long gcd=gcdExtended(b%a, a, y);
x[0]=y[1]-(b/a)*y[0];
x[1]=y[0];
return gcd;
}
public static int abs(int a,int b){
return (int)Math.abs(a-b);
}
public static long abs(long a,long b){
return (long)Math.abs(a-b);
}
public static int max(int a,int b){
if(a>b)
return a;
else
return b;
}
public static int min(int a,int b){
if(a>b)
return b;
else
return a;
}
public static long max(long a,long b){
if(a>b)
return a;
else
return b;
}
public static long min(long a,long b){
if(a>b)
return b;
else
return a;
}
public static long pow(long n,long p,long m){
long result = 1;
if(p==0)
return 1;
if (p==1)
return n;
while(p!=0)
{
if(p%2==1)
result *= n;
if(result>=m)
result%=m;
p >>=1;
n*=n;
if(n>=m)
n%=m;
}
return result;
}
public static long pow(long n,long p){
long result = 1;
if(p==0)
return 1;
if (p==1)
return n;
while(p!=0)
{
if(p%2==1)
result *= n;
p >>=1;
n*=n;
}
return result;
}
public static void debug(Object... o) {
System.out.println(Arrays.deepToString(o));
}
void run() throws Exception {
is = System.in;
out = new PrintWriter(System.out);
solve();
out.flush();
}
public static void main(String[] args) throws Exception {
new Thread(null, new Runnable() {
public void run() {
try {
new practice().run();
} catch (Exception e) {
e.printStackTrace();
}
}
}, "1", 1 << 26).start();
}
private byte[] inbuf = new byte[1024];
public int lenbuf = 0, ptrbuf = 0;
private int readByte() {
if (lenbuf == -1)
throw new InputMismatchException();
if (ptrbuf >= lenbuf) {
ptrbuf = 0;
try {
lenbuf = is.read(inbuf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (lenbuf <= 0)
return -1;
}
return inbuf[ptrbuf++];
}
private boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
private int skip() {
int b;
while ((b = readByte()) != -1 && isSpaceChar(b));
return b;
}
private double nd() {
return Double.parseDouble(ns());
}
private char nc() {
return (char) skip();
}
private String ns() {
int b = skip();
StringBuilder sb = new StringBuilder();
while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private char[] ns(int n) {
char[] buf = new char[n];
int b = skip(), p = 0;
while (p < n && !(isSpaceChar(b))) {
buf[p++] = (char) b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private char[][] nm(int n, int m) {
char[][] map = new char[n][];
for (int i = 0; i < n; i++)
map[i] = ns(m);
return map;
}
private int[] na(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = ni();
return a;
}
private long[] nl(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nl();
return a;
}
private int ni() {
int num = 0, b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
private long nl() {
long num = 0;
int b;
boolean minus = false;
while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
;
if (b == '-') {
minus = true;
b = readByte();
}
while (true) {
if (b >= '0' && b <= '9') {
num = num * 10 + (b - '0');
} else {
return minus ? -num : num;
}
b = readByte();
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n = int(input())
x = list(map(int, input().split()))
if x[0] + x[1] <= x[-1]:
print(1, 2, n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
if a[0]+a[1]<=a[-1]:
print("1 2", n)
else:
print("-1")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split(" ")))
chk=0
for x in range(n-2):
if a[x]+a[x+1]<=a[n-1]:
print(x+1,x+2,n)
chk=1
break;
if chk==0:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import math
for i in range(int(input())):
n = int(input())
ar = list(map(int,input().split()))
if ar[0] + ar[1] <= ar[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
while(t>0):
n=int(input())
a=list(map(int,input().split()))
s=a[0]+a[1]
ans=-1
for i in range(2,n):
if(a[i]>=s):
ans=i
else:
continue
if(ans!=-1):
print("1 2 "+str(ans+1))
else:
print(ans)
t-=1
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
def input(): return sys.stdin.readline().strip()
def iinput(): return int(input())
def rinput(): return map(int, sys.stdin.readline().strip().split())
def get_list(): return list(map(int, sys.stdin.readline().strip().split()))
mod = int(1e9)+7
def checkValidity(a, b, c):
if (a + b <= c) or (a + c <= b) or (b + c <= a) :
return True
else:
return False
for _ in range(iinput()):
n = iinput()
a = get_list()
if checkValidity(a[0], a[1], a[-1]):
print(1, 2, n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
ans = []
t = ini()
for _ in range(t):
n = ini()
a = inl()
if a[0] + a[1] <= a[n-1]:
ans.append(f"{1} {2} {n}")
else:
ans.append("-1")
print('\n'.join(ans))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
while t:
t-=1
n=int(input())
lst=list(map(int,input().split()))
res=-1
a=lst[0]
b=lst[1]
if n==3:
if a+b<=lst[2]:
res=3
else:
for i in range(2,n):
if a+b<=lst[i]:
res=i+1
break
if res==-1:
print(-1)
else:
print(1,2,res)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for i in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
if (l[0]+l[1]<=l[len(l)-1]):
print(1,2,len(l))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
# [int(s) for s in input().split()]
# int(input())
# input()
T = int(input())
for t in range(1,T+1):
N = int(input())
A = [int(s) for s in input().split()]
if A[0] + A[1] <= A[-1]:
print(1,2,N)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main(void) {
int n;
cin >> n;
while (n--) {
int t;
cin >> t;
map<int, int> mp;
int a[t], b[3];
for (int i = 0; i < t; i++) {
cin >> a[i];
mp[a[i]] = i + 1;
}
sort(b, b + 3);
if (a[0] + a[1] > a[t - 1]) {
cout << -1;
} else {
cout << 1 << " " << 2 << " " << t;
}
cout << endl;
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def solve(n, a):
a, b, c = a[0], a[1], a[-1]
if a + b > c:
print(-1)
else:
print(1, 2, n)
return
def main():
inp = lambda: [int(x) for x in input().split()]
tc = int(input())
for _ in range(tc):
n, a = int(input()), inp()
solve(n, a)
if __name__ == '__main__':
main()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class experiments
{
public static void main(String args[]) throws IOException
{
FastScanner fs = new FastScanner();
int T = fs.nextInt();
outer :while(T-->0)
{
int n =fs.nextInt();
int arr[] = fs.arrayIn(n);
int sum = arr[0]+arr[1];
for(int i=2; i<n; i++)
{
if(sum<=arr[i])
{
System.out.println("1 2 "+(i+1));
continue outer;
}
}
System.out.println(-1);
}
}
}
class FastScanner
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer str = new StringTokenizer("");
String next() throws IOException
{
while(!str.hasMoreTokens())
str = new StringTokenizer(br.readLine());
return str.nextToken();
}
char nextChar() throws IOException {
return next().charAt(0);
}
int nextInt() throws IOException
{
return Integer.parseInt(next());
}
float nextfloat() throws IOException
{
return Float.parseFloat(next());
}
double nextDouble() throws IOException
{
return Double.parseDouble(next());
}
long nextLong() throws IOException
{
return Long.parseLong(next());
}
byte nextByte() throws IOException
{
return Byte.parseByte(next());
}
int [] arrayIn(int n) throws IOException
{
int arr[] = new int[n];
for(int i=0; i<n; i++)
{
arr[i] = nextInt();
}
return arr;
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def no_triangle(arr):
arr.sort()
if arr[0]+arr[1]<=arr[-1]:
l = [1,2,len(arr)]
else:
l = []
return l
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
result = no_triangle(arr)
if result:
print(*result,sep=" ")
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
test=int(input())
for _ in range(test):
n=int(input())
list1=list(map(int,input().split()))
if list1[0]+list1[1]<=list1[n-1]:
print(1,2,n)
else:
print("-1")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n, flag1 = 0, flag2 = 0;
cin >> n;
long long a[n];
for (int i = 0; i < n; i++) cin >> a[i];
if ((a[0] + a[1]) <= a[n - 1]) {
cout << "1 "
<< "2 " << n << endl;
} else {
cout << "-1" << endl;
}
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
# cook your dish here
t = int(input())
while t>0:
n = int(input())
a = list(map(int, input().split()))
if a[0] + a[1] <= a[n-1]:
print("1 2 ",n)
else:
print("-1")
t = t-1
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t) :
n = int(input())
a = list(map(int,input().split()))
if a[0]+a[1] <= a[-1] :
print(1,2,n)
else :
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
v = [int(x) for x in input().split()]
if v[0] + v[1] <= v[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
struct HASH {
static uint64_t splitmix64(uint64_t x) {
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31);
}
size_t operator()(uint64_t x) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(x + FIXED_RANDOM);
}
static uint64_t splitmix64(const pair<long long, long long>& p) {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
long long x = p.first + FIXED_RANDOM, y = p.second + FIXED_RANDOM;
x += 0x9e3779b97f4a7c15;
x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
y += 0x9e3779b97f4a7c15;
y = (y ^ (y >> 30)) * 0xbf58476d1ce4e5b9;
y = (y ^ (y >> 27)) * 0x94d049bb133111eb;
return x ^ (x >> 31) ^ y ^ (y >> 31);
}
size_t operator()(const pair<long long, long long>& p) const {
static const uint64_t FIXED_RANDOM =
chrono::steady_clock::now().time_since_epoch().count();
return splitmix64(p);
}
};
const int dx4[4] = {-1, 0, 1, 0}, dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {-1, -1, 0, 1, 1, 1, 0, -1},
dy8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int n;
string str;
void solve() {
int m, a, b, c;
cin >> n;
int arr[n];
for (int i = 0; i < (int)n; i++) cin >> arr[i];
sort(arr, arr + n);
if (arr[0] + arr[1] <= arr[n - 1]) {
cout << "1 2 " << n << endl;
return;
}
cout << "-1\n";
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
;
int tc = 1;
cin >> tc;
while (tc--) {
solve();
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python2
|
for _ in range(input()):
n=input()
a=[int(i) for i in raw_input().split()]
flag=0
if(a[-1]>=a[0]+a[1]):
print 1,2,n
else:
print -1
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
#!/usr/bin/env python3
import io
import os
import sys
input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
def prdbg(*args, **kwargs):
print(*args, **kwargs)
pass
def get_str():
return input().decode().strip()
def rint():
return map(int, input().split())
def oint():
return int(input())
t = oint()
for _ in range(t):
n = oint()
a = list(rint())
b = a[0] + a[1]
for i in range(n-1, 1, -1):
if a[i] >= b:
print(1, 2, i+1)
break
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for j in range(int(input())):
a = int(input())
li = list(map(int,input().split()))
ma = li[a-1]
mi = li[0]
val = ma - mi
for j in range(1,a):
if li[j] <=val:
mid = j
print(1,j+1,a)
break
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
# 2200 rating
t=int(input())
for i in range(t):
n=input()
l=list(map(int,input().split()))
# print(l)
if l[0]+l[1]<=l[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
a = [int(i) for i in input().split()]
if a[0] + a[1] <= a[-1]:
print(1, 2, n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int,input().split()))
flag = 0
for i in range(2,n):
if(a[0]+a[1]<=a[i]):
print(1,2,i+1)
flag = 1
break
if (flag==0):
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
n = int(input())
A = list(map(int,input().split()))
if A[0] + A[1] <= A[-1]:
print("{} {} {}".format(1,2,n))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for i in range(t):
n = int(input())
mas = list(map(int, input().split()))
if (len(mas) < 3):
print(-1)
else:
if (mas[0]+mas[1] > mas[-1]):
print(-1)
else:
print(1,2,len(mas))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def triangle(a,b,c):
if a+b>c and b+c>a and a+c>b:
return True
else:
return False
for _ in range(int(input())):
a = int(input())
b = list(int(x) for x in input().split())
if triangle(b[0],b[1],b[-1])==False:
print(1,2,a)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
int a[50001];
for (int i = 0; i < n; i++) cin >> a[i];
if (a[0] + a[1] > a[n - 1]) {
cout << -1 << endl;
} else {
cout << 1 << " " << 2 << " " << n << endl;
}
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
a.sort()
if a[0]+a[1]<=a[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for i in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
for i in range(2,len(l)):
if l[0]+l[1]<=l[i]:
print(1,2,i+1)
break
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
c=l[n-1]
ok=False
p,q,r=0,0,0
for i in range(1,n-1):
if l[i]+l[i-1]<= c:
p,q=i,i-1
ok=True
if(ok):
print(q+1,p+1,n)
else:
print("-1")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def solve(a):
if a[0] + a[1] <= a[-1]:
return 1, 2, len(a)
return [-1]
for _ in range(int(input())):
n = int(input())
a = [int(x) for x in input().split()]
print(*solve(a))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
#import sys
#input = sys.stdin.readline
def solve():
n = int( input())
A = list( map( int, input().split()))
if A[0] + A[1] <= A[-1]:
return " ".join( map( str, [1,2,n]))
else:
return -1
def main():
t = int( input())
ANS = [ solve() for _ in range(t)]
print("\n".join( map(str, ANS)))
if __name__ == '__main__':
main()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n=int(input())
a=[int(i) for i in input().split()]
if a[0]+a[1]<=a[n-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
l1 = [int(x) for x in input().split()]
flag = 0
if l1[0]+l1[1]<=l1[-1]:
flag = 1
if flag:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
#pragma GCC optimizer("O3")
#pragma GCC target("sse4")
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
vector<long long int> a(n);
for (long long int i = 0; i < n; i++) cin >> a[i];
if ((a[0] + a[1]) <= a[n - 1]) {
cout << 1 << " " << 2 << " " << n << endl;
} else
cout << "-1\n";
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.Scanner;
public class p1398A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++) {
a[i]=sc.nextInt();
}
if(a[0]+a[1]<=a[n-1])
System.out.println("1 2 "+(n));
else
System.out.println("-1");
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input().split()[0])
for case in range(t):
n = int(input().split()[0])
a = list(map(int,input().split()))
if a[0] + a[1] <= a[n-1]:
print("1 2 "+ str(n))
else:
print("-1")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for i in range(t):
n=int(input())
list1=list(map(int,input().split()))
for i in range(n-1):
j=i+1
if (list1[i]+list1[j])>list1[n-1]:
print(-1)
break
else:
print(i+1,j+1,n)
break
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int32_t main() {
long long t;
cin >> t;
while (t--) {
long long n;
cin >> n;
long long arr[n];
for (long long i = 0; i < n; i++) {
cin >> arr[i];
}
vector<long long> ans;
long long temp = arr[n - 1] - arr[0];
long long i = 0;
for (i = 1; i < n; i++) {
if (arr[i] <= temp) {
cout << "1 " << i + 1 << " " << n << "\n";
break;
}
}
if (i == n) {
cout << "-1\n";
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
inp=sys.stdin.buffer.read().split(b"\n");_ii=-1
def rdln():
global _ii
_ii+=1
return inp[_ii]
inin=lambda typ=int: typ(rdln())
inar=lambda typ=int: [typ(x) for x in rdln().split()]
inst=lambda: rdln().strip().decode()
_T_=inin()
for _t_ in range(_T_):
n=inin()
a=inar()
if a[0]+a[1]>a[n-1]:
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t, n, val;
vector<int> v;
cin >> t;
for (int i = 0; i < t; i++) {
cin >> n;
for (int j = 0; j < n; j++) {
cin >> val;
v.push_back(val);
}
if (v[0] + v[1] > v[n - 1]) {
cout << -1 << endl;
} else {
cout << "1 "
<< "2 " << n << endl;
}
v.clear();
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
test_case = int(input())
for _ in range(test_case):
n = int(input())
a = list(map(int, input().split()))
if a[0] + a[1] <= a[-1]:
print(1, 2, n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
i_liczb = int(input())
liczby = list(map(int, input().split()))
a, b, c = liczby[0], liczby[1], liczby[-1]
if a + b <= c:
print(1, 2, i_liczb)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;
public class Temp {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);
Solution sol = new Solution();
int t = in.nextInt();
for (int i = 0; i < t; ++i)
sol.aSolve(in, out);
// sol.bSolve(in, out);
// sol.cSolve(in, out);
out.close();
}
private static class Solution {
private void aSolve(InputReader in, PrintWriter out) {
int n = in.nextInt();
long[] a = new long[n];
for (int i = 0; i < n; ++i)
a[i] = in.nextInt();
if (a[0] + a[1] <= a[n - 1]) {
out.println("1 2 " + n);
return;
}
out.println(-1);
}
private void bSolve(InputReader in, PrintWriter out) {
char[] s = in.next().toCharArray();
ArrayList<Integer> cons = new ArrayList<>();
int n = s.length;
for (int i = 0; i < n; ++i) {
int r = 0;
if (s[i] == '1') {
for (int j = i; j<n; ++j) {
if (s[j] == '1') {
r++;
if (j + 1 == n) {
cons.add(r);
i = j;
}
}
else if (s[j] == '0') {
cons.add(r);
i = j;
break;
}
}
}
}
Collections.sort(cons);
Collections.reverse(cons);
int ans = 0;
boolean alice = true;
for (int i = 0; i < cons.size(); ++i) {
if (alice) {
ans += cons.get(i);
alice = false;
} else {
alice = true;
}
}
out.println(ans);
}
private void cSolve(InputReader in, PrintWriter out) {
int n = in.nextInt();
char[] dum = in.next().toCharArray();
int[] a = new int[n];
for (int i = 0; i < n; ++i)
a[i] = dum[i] - '0';
int ans = 0;
for (int i = 0; i < n; ++i) {
int pref = a[i];
for (int j = 0; j < n; ++j) {
if (pref == j - i + 1) {
++ans;
break;
}
if (i == j) continue;
pref += a[j];
// out.println(pref + " " + (j - i));
}
}
out.println(ans);
}
}
private static class InputReader {
private BufferedReader reader;
private StringTokenizer tokenizer;
private InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 9000000);
tokenizer = null;
}
private String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
private int nextInt() {
return Integer.parseInt(next());
}
private long nextLong() {
return Long.parseLong(next());
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
vector<vector<int>> v(t);
int n;
int temp;
for (int i = 0; i < t; i++) {
cin >> n;
v[i].reserve(n);
for (int j = 0; j < n; j++) {
cin >> temp;
v[i].push_back(temp);
}
}
for (int i = 0; i < t; i++) {
if (v[i][v[i].size() - 1] >= v[i][0] + v[i][1])
cout << 1 << " " << 2 << " " << v[i].size() << endl;
else
cout << -1 << endl;
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
while(t>0):
n = int(input())
arr = list(map(int, input().split()))
if(arr[0]+arr[1]>arr[n-1]):
print(-1)
else:
print(1, 2, n)
t-=1
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
long long int n;
cin >> n;
long long int a[n];
for (int i = 0; i < n; i++) cin >> a[i];
if (a[0] + a[1] > a[n - 1])
cout << -1 << endl;
else
cout << 1 << " " << 2 << " " << n << endl;
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
void solve(bool& flag) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; i++) {
cin >> a[i];
}
if (n < 3) {
return;
} else {
if (a[0] + a[1] <= a[n - 1]) {
cout << 1 << " " << 2 << " " << n << endl;
flag = true;
}
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int test;
cin >> test;
while (test--) {
bool flag = false;
solve(flag);
if (not flag) {
cout << -1 << endl;
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.Scanner;
public class BadTriangle {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0)
{
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++)
{
arr[i]=sc.nextInt();
}
for(int i=0;i<=n-3;i++)
{
int j=i+1;
if(arr[i]+arr[j]<=arr[n-1])
{
System.out.print(i+1+" "+(j+1)+" "+n);
System.out.println();
break;
}
else
{
System.out.print("-1");
System.out.println();
break;
}
}
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int,input().split(' ')))
i,j,k = 0,1,2
while i < n-2:
while j < n-1 :
while k < n:
if a[i] + a[j] <= a[k]:
print(i+1,j+1,k+1)
i,j,k = n,n,n
break
else:
k += 1
j += 1
i += 1
if i == n-2 and j == n - 1 and k == n:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
#!/usr/bin/env python
import os
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from io import BytesIO, IOBase
from itertools import (
accumulate, combinations, combinations_with_replacement, groupby,
permutations, product)
from math import (
acos, asin, atan, ceil, cos, degrees, factorial, hypot, log2, pi, radians,
sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits
def inp():
return(int(input()))
def inlist():
return(list(map(int, input().split())))
def instr():
s = input()
return(list(s[:len(s)]))
def invr():
return(map(int, input().split()))
def main():
t = inp()
for _ in range(t):
n = inp()
d = inlist()
a = d[0]
b = d[1]
c = d[-1]
if a + b > c and a + c > b and b + c > a:
print(-1)
else:
print(1, 2, n)
# region fastio
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mode or "r" not in file.mode
self.write = self.buffer.write if self.writable else None
def read(self):
while True:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
if not b:
break
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines = 0
return self.buffer.read()
def readline(self):
while self.newlines == 0:
b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
self.newlines = b.count(b"\n") + (not b)
ptr = self.buffer.tell()
self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
self.newlines -= 1
return self.buffer.readline()
def flush(self):
if self.writable:
os.write(self._fd, self.buffer.getvalue())
self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
def __init__(self, file):
self.buffer = FastIO(file)
self.flush = self.buffer.flush
self.writable = self.buffer.writable
self.write = lambda s: self.buffer.write(s.encode("ascii"))
self.read = lambda: self.buffer.read().decode("ascii")
self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
def input(): return sys.stdin.readline().rstrip("\r\n")
# endregion
if __name__ == "__main__":
main()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
dict={}
for i in range(t):
a=input()
b=input().split(" ")
m=len(b)
for i in range(m):
if int(b[0])+int(b[1])>int(b[m-1]):
print(-1)
break
else:
print(1,2,m)
break
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for i in range(t):
n=int(input())
a=[int(v) for v in input().split()]
p=a[0]
q=a[1]
r=a[-1]
if p+q<=r:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
print("-1" if arr[0]+arr[1]>arr[n-1] else f"1 2 {n}")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def tc():
n = int(input())
a = list(map(int, input().split()))
if a[0] + a[1] > a[-1]:
print(-1)
else:
print(1, 2, n)
#################
T = int(input())
for _ in range(T):
tc()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for time in range(int(input())):
l=int(input())
op=[]
rt=input().split()
op=rt
for er in range(l):
op[er]=int(op[er])
x=op[0]
y=op[1]
z=op[-1]
if z>=x+y:
print(1,2,l)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
T=int(input())
for t in range(T):
n=int(input())
l=[int(k) for k in input().split()]
i=0
j=1
k=2
f=0
for m in range(2,n):
if(l[i]+l[j]<=l[m]):
k=m
f=1
break
if(f==1):
print(i+1,j+1,k+1)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import io,os
from collections import deque
import bisect
from collections import deque
#input = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
RL = lambda : list(map(int, input().split(' ')))
T = int(input())
for _ in range(T):
n = int(input())
l = RL()
if l[0]+l[1]<=l[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.*;
public class Test{
public static void main(String[] a__){
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
int len = sc.nextInt();
int[] a = new int[len];
boolean isValid=false;
for(int i=0; i<len; i++)
a[i]=sc.nextInt();
int f = a[len-1]-a[0];
for(int i=1; i<len-1; i++){
if(a[i]<=f){
isValid=true;
System.out.println(1+" "+(i+1)+" "+len);
break;
}
}
if(!isValid)
System.out.println(-1);
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys #
inp=sys.stdin.buffer.readline
inin=lambda typ=int: typ(inp())
inar=lambda typ=int: [typ(x) for x in inp().split()]
inst=lambda : inp().decode().strip()
_T_=inin()
for _t_ in range(_T_):
n=inin()
a=inar()
if a[0]+a[1]>a[n-1]:
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for i in range(t):
a = [-1]
n=int(input())
arr = list(map(int,input().split()))
for j in range(2,n):
if arr[0]+arr[1]<=arr[j]:
a=[1,2,j+1]
for item in a:
print(item, end=" ")
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for _ in range(t):
n=int(input())
l=list(map(int,input().split()))
if(l[0]+l[1]<=l[n-1]):
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
if(a[0]+a[1]>a[-1]):
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n = int(input())
ls = list(map(int, input().split()))
if ls[0] + ls[1] > ls[-1]:
print(-1)
else:
print(1, 2, n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
T = int(input())
for t in range(T):
n = int(input())
xs = [int(x) for x in input().split()]
# for i in range(len(xs)-2):
# if xs[i]+xs[i+1] >= xs[i+2]:
# print(i+1, i+2, i+3)
# break
# else:
# print(-1)
# lol I thought the prompt was the inverse
if xs[0] + xs[1] <= xs[len(xs)-1]:
print(1, 2, len(xs))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
FastReader sc = new FastReader();
int tt = sc.nextInt();
while(tt-- > 0){
int n = sc.nextInt();
int[] arr = sc.readArray(n);
if(arr[0] + arr[1] <= arr[n - 1]){
System.out.println("1 2 " + n);
}else
System.out.println(-1);
}
}
private static class FastReader {
private BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] readArray(int n){
int[] arr = new int[n];
for(int i = 0; i < n; ++i)
arr[i] = nextInt();
return arr;
}
long[] readLongArray(int n){
long[] arr = new long[n];
for(int i = 0; i < n; ++i)
arr[i] = nextLong();
return arr;
}
double[] readDoubleArray(int n){
double[] arr = new double[n];
for(int i = 0; i < n; ++i)
arr[i] = nextDouble();
return arr;
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for i in range(int(input())):
n = int(input())
k = 0
mas = [int(i) for i in input().split()]
for i in range(2, n):
if mas[0] + mas[1] <= mas[i]:
print(1, 2, i+1)
k += 1
break
if k == 0:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import math
from collections import deque
from sys import stdin, stdout
from string import ascii_letters
input = stdin.readline
#print = stdout.write
letters = ascii_letters[:26]
for _ in range(int(input())):
n = int(input())
arr = list(map(int, input().split()))
first = arr[0]
second = arr[-1]
can = False
res = 0
for i in range(1, n - 1):
if arr[i] + first <= second or arr[i] + second <= first:
can = True
res = i
break
if can:
print(*[1, res + 1, n])
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
if(a[-1]>=(a[0]+a[1])):print(1,2,n)
else:print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import math
from collections import Counter,defaultdict
I =lambda:int(input())
M =lambda:map(int,input().split())
LI=lambda:list(map(int,input().split()))
for _ in range(I()):
n=I()
a=LI()
if a[0]+a[1]<=a[-1]:
print(1,2,n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
for i in range(int(input())):
n = int(input())
arr = [int(elem) for elem in input().split()]
if arr[0]+arr[1] <= arr[-1]:
print(1, 2, len(arr))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
import java.util.*;
public class P1398A800 {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
int tests = Integer.parseInt(scan.nextLine());
for(int i = 0; i < tests; i++){
int answer = -1;
int len = Integer.parseInt(scan.nextLine());
String[] nums = scan.nextLine().trim().split(" ");
if(Integer.parseInt(nums[0]) + Integer.parseInt(nums[1]) <= Integer.parseInt(nums[len-1])){
System.out.println("1 2 " + len);
}
else{
System.out.println(-1);
}
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import math
t=int(input())
for w in range(t):
n=int(input())
l=sorted([int(i) for i in input().split()])
if(l[0]+l[1]>l[-1]):
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for i in range(0 ,t):
input()
A = list(map(lambda x: int(x), input().split()))
A.sort()
if A[0]+A[1] <= A[-1]:
print(1, 2, len(A))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t=int(input())
for _ in range(0,t):
n=int(input())
a=list(map(int,input().split()))
p=0
for i in range(len(a)-1,1,-1):
if a[0]+a[1]<=a[i]:
p=1
break
if p==1:
print(1,2,(i+1))
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
input=sys.stdin.buffer.readline
inin=lambda: int(input())
inar=lambda: list(map(int,input().split()))
inst=lambda: sys.stdin.readline().rstrip('\n\r')
INF=float('inf')
#from collections import deque as que, defaultdict as vector, Counter
#from bisect import bisect as bsearch
#from heapq import heapify, heappush as hpush, heappop as hpop
'''from types import GeneratorType
def recursive(f, stack=[]):
def wrappedfunc(*args, **kwargs):
if stack:
return f(*args, **kwargs)
else:
to = f(*args, **kwargs)
while True:
if type(to) is GeneratorType:
stack.append(to)
to = next(to)
else:
stack.pop()
if not stack:
break
to = stack[-1].send(to)
return to
return wrappedfunc'''
_T_=inin()
for _t_ in range(_T_):
n=inin()
a=inar()
if a[0]+a[1]>a[n-1]:
print(-1)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
t = int(input())
for i in range(t):
n = int(input())
s = input().split()
a = list(map(int, s))
if a[0] + a[1] > a[len(a)-1]:
print(-1)
else:
print(1, 2, len(a))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
from sys import stdin
###############################################################
def iinput(): return int(stdin.readline())
def minput(): return map(int, stdin.readline().split())
def linput(): return list(map(int, stdin.readline().split()))
###############################################################
t = iinput()
while t:
t-=1
n = iinput()
a = linput()
for i in range(2, n):
if a[i] >= a[0]+a[1]:
print(1, 2, i+1)
break
else: print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
import math
from functools import reduce
import bisect
def getN():
return int(input())
def getNM():
return map(int, input().split())
def getList():
return list(map(int, input().split()))
def input():
return sys.stdin.readline().rstrip()
def index(a, x):
i = bisect.bisect_left(a, x)
if i != len(a) and a[i] == x:
return i
return False
#############
# MAIN CODE #
#############
for _ in range(int(input())):
n = getN()
arr = getList()
if arr[0] + arr[1] <= arr[-1]:
print(1, 2, n)
else:
print(-1)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
java
|
/*
/$$$$$ /$$$$$$ /$$ /$$ /$$$$$$
|__ $$ /$$__ $$| $$ | $$ /$$__ $$
| $$| $$ \ $$| $$ | $$| $$ \ $$
| $$| $$$$$$$$| $$ / $$/| $$$$$$$$
/$$ | $$| $$__ $$ \ $$ $$/ | $$__ $$
| $$ | $$| $$ | $$ \ $$$/ | $$ | $$
| $$$$$$/| $$ | $$ \ $/ | $$ | $$
\______/ |__/ |__/ \_/ |__/ |__/
/$$$$$$$ /$$$$$$$ /$$$$$$ /$$$$$$ /$$$$$$$ /$$$$$$ /$$ /$$ /$$ /$$ /$$$$$$$$ /$$$$$$$
| $$__ $$| $$__ $$ /$$__ $$ /$$__ $$| $$__ $$ /$$__ $$| $$$ /$$$| $$$ /$$$| $$_____/| $$__ $$
| $$ \ $$| $$ \ $$| $$ \ $$| $$ \__/| $$ \ $$| $$ \ $$| $$$$ /$$$$| $$$$ /$$$$| $$ | $$ \ $$
| $$$$$$$/| $$$$$$$/| $$ | $$| $$ /$$$$| $$$$$$$/| $$$$$$$$| $$ $$/$$ $$| $$ $$/$$ $$| $$$$$ | $$$$$$$/
| $$____/ | $$__ $$| $$ | $$| $$|_ $$| $$__ $$| $$__ $$| $$ $$$| $$| $$ $$$| $$| $$__/ | $$__ $$
| $$ | $$ \ $$| $$ | $$| $$ \ $$| $$ \ $$| $$ | $$| $$\ $ | $$| $$\ $ | $$| $$ | $$ \ $$
| $$ | $$ | $$| $$$$$$/| $$$$$$/| $$ | $$| $$ | $$| $$ \/ | $$| $$ \/ | $$| $$$$$$$$| $$ | $$
|__/ |__/ |__/ \______/ \______/ |__/ |__/|__/ |__/|__/ |__/|__/ |__/|________/|__/ |__/
*/
import java.io.*;
import java.util.*;
import java.math.*;
public class cf
{
// static class pair{
// long x;
// Long y;
// public pair(long x,long y){
// this.x=x;
// this.y=y;
// }
// }
public static void main(String args[]) throws IOException
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int a[]=new int[n];
for(int i=0;i<n;i++){
a[i]=sc.nextInt();
}
if(a[n-1]>=(a[0]+a[1])){
System.out.println("1 2 "+n);
}
else{
System.out.println("-1");
}
}
}
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
def run():
num = int(input())
nums = [int(i) for i in input().split()]
if nums[0] + nums[1] <= nums[-1]:
print(1, 2, num)
else:
print(-1)
n = int(input())
for i in range(n):
run()
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
cpp
|
#include <bits/stdc++.h>
using namespace std;
int main() {
int prmin, mn, mx, n, hh, x, prmini, mni = -1, mxi;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> hh;
prmin = 1000000001;
mn = 1000000001;
mx = -1;
for (int j = 0; j < hh; j++) {
cin >> x;
if (x < mn) {
prmin = mn;
mn = x;
prmini = mni;
mni = j;
} else if (x < prmin) {
prmin = x;
prmini = j;
} else if (x > mx) {
mx = x;
mxi = j;
}
}
if (mn + prmin > mx) {
cout << -1 << endl;
} else {
cout << mni + 1 << " " << prmini + 1 << " " << mxi + 1 << endl;
}
}
return 0;
}
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
ans = []
t = ini()
for _ in range(t):
n = ini()
a = inl()
out = False
i = 0
j = 2
while j < n:
if a[i] + a[i+1] <= a[j]:
out = True
break
else:
j += 1
if out:
ans.append(f"{i+1} {i+2} {j+1}")
else:
ans.append("-1")
print('\n'.join(ans))
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys, collections, math
def get_ints(): return map(int, sys.stdin.readline().strip().split())
def get_array(): return list(map(int, sys.stdin.readline().strip().split()))
def input(): return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
n = int(input())
arr = get_array(); flag = False
if (arr[0] + arr[1] > arr[n - 1]):
if (arr[1] + arr[n - 1] > arr[0]):
if (arr[n - 1] + arr[0] > arr[1]):
print(-1)
else:
print(1, 2, n)
else:
print(1,2,n)
else:
print(1,2,n)
|
1398_A. Bad Triangle
|
You are given an array a_1, a_2, ... , a_n, which is sorted in non-decreasing order (a_i β€ a_{i + 1}).
Find three indices i, j, k such that 1 β€ i < j < k β€ n and it is impossible to construct a non-degenerate triangle (a triangle with nonzero area) having sides equal to a_i, a_j and a_k (for example it is possible to construct a non-degenerate triangle with sides 3, 4 and 5 but impossible with sides 3, 4 and 7). If it is impossible to find such triple, report it.
Input
The first line contains one integer t (1 β€ t β€ 1000) β the number of test cases.
The first line of each test case contains one integer n (3 β€ n β€ 5 β
10^4) β the length of the array a.
The second line of each test case contains n integers a_1, a_2, ... , a_n (1 β€ a_i β€ 10^9; a_{i - 1} β€ a_i) β the array a.
It is guaranteed that the sum of n over all test cases does not exceed 10^5.
Output
For each test case print the answer to it in one line.
If there is a triple of indices i, j, k (i < j < k) such that it is impossible to construct a non-degenerate triangle having sides equal to a_i, a_j and a_k, print that three indices in ascending order. If there are multiple answers, print any of them.
Otherwise, print -1.
Example
Input
3
7
4 6 11 11 15 18 20
4
10 10 10 11
3
1 1 1000000000
Output
2 3 6
-1
1 2 3
Note
In the first test case it is impossible with sides 6, 11 and 18. Note, that this is not the only correct answer.
In the second test case you always can construct a non-degenerate triangle.
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n"
]
}
|
{
"input": [
"3\n7\n4 6 11 11 15 18 20\n4\n10 10 10 11\n3\n1 1 1000000000\n",
"1\n6\n1 1 1 2 2 3\n",
"1\n3\n21 78868 80000\n",
"1\n14\n1 2 2 2 2 2 2 2 2 2 2 2 2 4\n",
"1\n3\n78788 78788 157577\n",
"1\n3\n5623 5624 10000000\n",
"1\n10\n1 7 7 7 7 9 9 9 9 9\n",
"1\n3\n5739271 5739272 20000000\n",
"1\n3\n1 65535 10000000\n",
"1\n3\n78788 78788 100000\n",
"1\n15\n3 4 7 8 9 10 11 12 13 14 15 16 32 36 39\n"
],
"output": [
"1 2 7\n-1\n1 2 3\n",
"1 2 6\n",
"1 2 3\n",
"1 2 14\n",
"1 2 3\n",
"1 2 3\n",
"1 2 10\n",
"1 2 3\n",
"1 2 3\n",
"-1\n",
"1 2 15\n"
]
}
|
CORRECT
|
python3
|
import sys
t = int(sys.stdin.readline())
for _ in range(t):
n = int(sys.stdin.readline())
m = {}
A = list(map(int, sys.stdin.readline().split()))
i = 0
j = n - 2
k = n - 1
f = False
while i < j:
if A[i] + A[j] <= A[k]:
f = True
break
else:
j -= 1
if f:
print(i + 1, j + 1, k + 1)
else:
print(-1)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.