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
tc=int(input()) for _ in range(tc): n=int(input()) a=list(map(int,input().split())) i,j,k=0,1,n-1 if a[i]+a[j]<=a[k]: 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
java
import java.util.*; public class GFG { 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(); } if(arr[0]+arr[1]>arr[n-1]) System.out.println("-1"); else System.out.println("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
n = int(input()) for _ in range(n): a = int(input()) l = list(map(int,input().split())) if l[0]+l[1]<=l[a-1]: print(1,2,a,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
t=int(input()) for _ in range(t): n=int(input()) l=list(map(int,input().split())) flag=0 if(len(l)<=2): print(-1) else: for i in range(n-1): if(l[i]+l[i+1]<=l[-1]): flag=1 ans=i+1 ans1=i+2 ans3=n break if(flag==0): print(-1) else: print(ans,ans1,ans3)
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()) 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
import math def gcd(a,b): if (b == 0): return a return gcd(b, a%b) def lcm(a,b): return (a*b) / gcd(a,b) def bs(arr, l, r, x): while l <= r: mid = l + (r - l)//2; if(arr[mid]==x): return arr[mid] elif(arr[mid]<x): l = mid + 1 else: r = mid - 1 return -1 def swap(list, pos1, pos2): list[pos1], list[pos2] = list[pos2], list[pos1] return list def subarrayBitwiseOR(A): res = set() pre = {0} for x in A: pre = {x | y for y in pre} | {x} res |= pre return len(res) t = int(input()) for _ in range(t): n = int(input()) a = list(map(int,input().split())) x = a[0] y = a[1] for i in range(2,n): z = a[i] if(x+y<=z or y+z<=x or z+x<=y): 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
java
import java.util.*; import java.io.*; public class Main{ public static void main(String[] args) { MyScanner sk = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); int totalNumOfCases = sk.nextInt(); for (int i = 0; i < totalNumOfCases; i++){ Vector<Integer> storage = new Vector<>(); int m = sk.nextInt(); int index = 0; while (index < m) { storage.add(sk.nextInt()); index ++; } boolean boo = false; for (int j = 2; j < m; j++) { int sum = storage.get(0), sum1 = storage.get(1); if (sum + sum1 <= storage.get(j)){ int p = j+1; out.println(1 + " " + 2 + " " + p); boo = true; break; } } if (!boo) out.println(-1); // Stop writing your solution here. ------------------------------------- } out.close(); } //-----------PrintWriter for faster output--------------------------------- public static PrintWriter out; //-----------MyScanner class for faster input---------- public static class MyScanner { BufferedReader br; StringTokenizer st; public MyScanner() { 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; } } //-------------------------------------------------------- }
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[n-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
for _ in range(int(input())): n = int(input()) A = list(map(int, 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
for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) if l[-1]>=l[0]+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
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); int T; cin >> T; while (T--) { int n, i, j, k; cin >> n; int a[n]; vector<pair<int, int>> v; for (i = 0; i < n; i++) { cin >> a[i]; v.push_back({a[i], i}); } sort(v.begin(), v.end()); if (v[0].first + v[1].first <= v[v.size() - 1].first || v[0].first + v[v.size() - 1].first <= v[1].first || v[v.size() - 1].first + v[1].first <= v[1].first) { cout << 1 << " " << 2 << " " << v.size() << endl; } else 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.io.*; import java.lang.*; import java.io.InputStream; import java.io.InputStreamReader; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.io.IOException; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; import java.math.BigInteger; public class CodeforcesEdu93 { //code written by a living bruh moment public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStream); Task solver = new Task(); int t = in.nextInt(); for (int tt = 1; tt <= t; tt++) solver.solve(tt, in, out); out.close(); } static class Task { public void solve(int tt, InputReader in, PrintWriter out) { int n = in.nextInt(); long[] a = in.nextLonga(n); long sum1 = a[0] + a[1]; long sum2 = a[n-1]; out.println(sum2>=sum1?"1 2 " + (n):-1); } } static void sort(int[] x) { shuffle(x); Arrays.sort(x); } static void sort(long[] x) { shuffle(x); Arrays.sort(x); } static void shuffle(int[] a) { Random get = new Random(); for (int i = 0; i < a.length; i++) { int r = get.nextInt(a.length); int temp = a[i]; a[i] = a[r]; a[r] = temp; } } static void shuffle(long[] a) { Random get = new Random(); for (int i = 0; i < a.length; i++) { int r = get.nextInt(a.length); long temp = a[i]; a[i] = a[r]; a[r] = temp; } } static class InputReader { public BufferedReader reader; public StringTokenizer tokenizer; public InputReader(InputStream stream) { reader = new BufferedReader(new InputStreamReader(stream), 32768); tokenizer = null; } public String next() { while (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String nextLine() { try { return reader.readLine(); } catch (Exception e) { e.printStackTrace(); } return null; } public boolean hasNext() { String next = null; try { next = reader.readLine(); } catch (Exception e) { } if (next == null) { return false; } tokenizer = new StringTokenizer(next); return true; } public int[] nextInta(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLonga(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return a; } public int[][] nextIntm(int n, int m) { int[][] a = new int[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = nextInt(); } } return a; } public long[][] nextLongm(int n, int m) { long[][] a = new long[n][m]; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { a[i][j] = nextLong(); } } return a; } public BigInteger nextBigInteger() { return new BigInteger(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
python3
import math from decimal import Decimal import heapq import copy import heapq from collections import deque from collections import defaultdict MOD = 1000000007 def na(): n = int(input()) b = [int(x) for x in input().split()] return n,b def nab(): n = int(input()) b = [int(x) for x in input().split()] c = [int(x) for x in input().split()] return n,b,c def dv(): n, m = map(int, input().split()) return n,m def da(): n, m = map(int, input().split()) a = list(map(int, input().split())) return n,m, a def dva(): n, m = map(int, input().split()) a = [int(x) for x in input().split()] b = [int(x) for x in input().split()] return n,m,b def eratosthenes(n): sieve = list(range(n + 1)) for i in sieve: if i > 1: for j in range(i + i, len(sieve), i): sieve[j] = 0 return sorted(set(sieve)) def lol(lst,k): k=k%len(lst) ret=[0]*len(lst) for i in range(len(lst)): if i+k<len(lst) and i+k>=0: ret[i]=lst[i+k] if i+k>=len(lst): ret[i]=lst[i+k-len(lst)] if i+k<0: ret[i]=lst[i+k+len(lst)] return(ret) def nm(): n = int(input()) b = [int(x) for x in input().split()] m = int(input()) c = [int(x) for x in input().split()] return n,b,m,c def dvs(): n = int(input()) m = int(input()) return n, m def fact(n): tc = [] ans = {} d = 2 while d * d <= n: if n % d == 0: tc.append(d) n //= d else: d += 1 if n > 1: tc.append(n) for i in tc: ans[i] = ans.get(i, 0) + 1 return ans def to_zero(n, s): lst = s[0] ans = [] for i in range(n): if lst == s[i]: continue else: if lst == '0': lst = '1' ans.append(i) else: lst = '0' ans.append(i) if lst == '1': ans.append(n) return ans for _ in range(int(input())): n, a = na() if a[-1] < a[0] + 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
T = int(input()) for _ in range(T): 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
for test in range(int(input())): n = int(input()) arr = list(map(int,input().split())) if arr[0] + arr[1] > arr[-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
# -*- coding: utf-8 -*- """ Created on Fri Aug 14 20:14:36 2020 @author: sachd """ t=int(input()) for i in range(t): n=int(input()) s=input().split() ls=[] for j in range(len(s)): ls.append(int(s[j])) c=ls[n-1] a=ls[0] b=ls[1] if a+b>c: print(-1) else: print(1), print(2), print(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()) a = list(map(int, input().split())) s = a[0] + a[1] # i = 2 f = 0 for i in range(2, n): if a[i] >= s: print(1, 2, i + 1) f = 1 break if f == 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 #another one inp=sys.stdin.buffer.readline read=lambda: list(map(int,inp().split())) input=lambda : inp().decode().strip() _T_,=read() for _t_ in range(_T_): n,=read() a=read() 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
import os inp=os.read(0,os.fstat(0).st_size).split(b"\n");_ii=-1 def rdln(): global _ii _ii+=1 return inp[_ii] inin=lambda: int(rdln()) inar=lambda: [int(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
python3
T = int(input()) def solve(): n = int(input()) a = list(map(int, input().split())) #print(a[-1]) if(a[0] + a[1] <= a[-1]): print("%d %d %d" % (1, 2, n)) else: print(-1) for t in range(T): 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
for _ in range(int(input())): n=int(input()) a=list(map(int,input().split())) c=1 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 sys input = sys.stdin.readline def inInt(): return int(input()) def inStr(): return input().strip("\n") def inIList(): return(list(map(int,input().split()))) def inSList(): return(input().split()) def solve(n, nums): if nums[0] + nums[1] <= nums[len(nums)-1]: print(1, 2, len(nums)) else: print("-1") t = inInt() for case in range(t): n = inInt() nums = inIList() solve(n, nums)
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.ArrayList; import java.util.List; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner scn = new Scanner(System.in); int t= scn.nextInt(); List<Integer[]> listOfArr = new ArrayList<Integer[]>(); for(int i=0 ; i<t; i++) { int n = scn.nextInt(); Integer[] arr = new Integer[n]; for(int j=0; j<n; j++) { arr[j] = scn.nextInt(); } listOfArr.add(arr); } for(Integer[] item: listOfArr) { if(item[0]+ item[1] <= item[item.length-1] ) { System.out.println("1 2 "+(item.length)); }else{ System.out.println(-1); } } System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); System.out.println(); } }
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()) for _ in range(n): m = int(input()) a=list(map(int,input().split())) if a[0]+a[1]<=a[-1]: print(1,2,m) 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 case in range(t): n = int(input()) a = [int(s) for s in 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
t = int(input()) for i in range(t): s = int(input()) arr = list(map(int, input().split())) if ((arr[0]+arr[1])<=arr[-1]): print(1,2,s) 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 collections def solve(lst): if len(lst) < 3: return -1 if lst[0] + lst[1] <= lst[len(lst)-1]: return str(1) + " "+str(2)+ " " +(str(len(lst))) return -1 def sort(key): return key[0] ans=[] n = int(input()) for i in range(n): k=int(input()) lst= list(map(int,input().split())) ans.append(solve(lst)) for i in ans: print(i) # for i in ans: # print(i)
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 # coding: utf-8 # In[1]: try: 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,2,n) else: print(-1) t = t-1 except EOFError: print(" ") # In[ ]:
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 n = int(sys.stdin.readline()) for _ in range(n): m = int(sys.stdin.readline()) arr = list(map(int, sys.stdin.readline().split())) if arr[0]+arr[1] <= arr[-1]: print(f"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
python3
import bisect def multiple_input(): return map(int, input().split()) def list_input(): return list(map(int, input().split())) for _ in range(int(input())): n = int(input()) a = list_input() s = a[0] + a[1] x = a[-1] if s > x: 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
def call(): n=int(input()) l=[int(x) for x in input().split()] if(l[0]+l[1]>l[-1]): print(-1) else: print(1,2,n) for _ in range(int(input())): call()
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 bad_triangle(n, a): if(len(a)<3): return -1 if(a[-1]<a[0]+a[1]): return -1 else: return [1, 2, n] test = int(input()) for i in range(test): n = int(input()) a = list(map(int, input().split())) ans = bad_triangle(n, a) if(ans==-1): print(-1) else: 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
from sys import stdin,stdout from collections import defaultdict input=lambda:stdin.readline().strip() for _ in range(int(input())): n=int(input()) lst=list(map(int,input().split())) sum1=lst[0]+lst[1] if sum1<=lst[-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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.LinkedList; import java.util.Map; import java.util.StringTokenizer; public class Test { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; int T = Integer.parseInt(br.readLine()); for(int test=0; test<T; test++) { int N = Integer.parseInt(br.readLine()); st = new StringTokenizer(br.readLine()); int[] a = new int[N+1]; for(int i=1; i<=N; i++) { a[i] = Integer.parseInt(st.nextToken()); } boolean check = false; boolean check2 = false; int one = 1; int two = 2; int three = N; while(a[one] + a[two] > a[three]) { if(one == N-2) { check = true; break; } if(!check2) { if(two==N-1) { check2 = true; } two++; }else { one++; } } if(check) { System.out.println(-1); }else { System.out.println(one +" "+ two +" "+ three); } } } }
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 Div2EducationalRound93A { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int t=s.nextInt(); while(t--!=0){ int n=s.nextInt(); int[] arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=s.nextInt(); } boolean flag=false; for(int i=0;i<n-2;i++){ int v1=arr[i]; int j=i+1; //for(j=n-2;j>i;j--){ int v2=arr[j]; int r=v1+v2; if(r<=arr[n-1]){ flag=true; int i1=i+1,i2=j+1,i3=n; System.out.println(i1+" "+i2+" "+i3); break; // } } if(flag==true) break; } if(flag==false){ 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 solver(arr): k = len(arr)-1 if arr[0]+arr[1]<=arr[k]: return [1,2,k+1] else: return [-1] for t in range(int(input())): _ = int(input()) arr = list(map(int,input().split())) for i in solver(arr): print(i,end=' ') print()
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,b,c = A[0],A[1],A[-1] if a+b <= c: 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.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; FastReader in = new FastReader(inputStream); PrintWriter out = new PrintWriter(outputStream); ABadTriangle solver = new ABadTriangle(); solver.solve(1, in, out); out.close(); } static class ABadTriangle { public void solve(int testNumber, FastReader s, PrintWriter out) { int t = s.nextInt(); while (t-- > 0) { int n = s.nextInt(); int[] arr = s.nextIntArray(n); if (arr[0] + arr[1] <= arr[n - 1]) { out.println("1 2 " + n); } else { out.println(-1); } } } } static class FastReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private int numChars; private FastReader.SpaceCharFilter filter; public FastReader(InputStream stream) { this.stream = stream; } public int read() { if (numChars == -1) { throw new InputMismatchException(); } if (curChar >= numChars) { curChar = 0; try { numChars = stream.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) { return -1; } } return buf[curChar++]; } public int nextInt() { int c = read(); while (isSpaceChar(c)) { c = read(); } int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') { throw new InputMismatchException(); } res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public boolean isSpaceChar(int c) { if (filter != null) { return filter.isSpaceChar(c); } return isWhitespace(c); } public static boolean isWhitespace(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } public int[] nextIntArray(int n) { int[] array = new int[n]; for (int i = 0; i < n; ++i) array[i] = nextInt(); return array; } public interface SpaceCharFilter { public boolean isSpaceChar(int ch); } } }
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 fun(a, n): if a[0] + a[1] <= a[-1]: return [1, 2, n] return [-1] for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) print(*fun(a,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; cin >> t; while (t--) { int n, x, a = 0, b = -1; cin >> n; for (int i = 0; i < n; i++) { cin >> x; if (i == 0 || i == 1) a += x; if (i == n - 1 && x >= a) b = i + 1; } if (b == -1) cout << -1 << "\n"; else cout << 1 << " " << 2 << " " << b << "\n"; } 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 i 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
for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) i = n-3 while i>=0 and a[i]+a[i+1]>a[n-1]: i-=1 if i==-1: print(-1) else: print(i+1,i+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
from sys import stdin inp = lambda : stdin.readline().strip() t = int(inp()) for _ in range(t): n = int(inp()) a = [int(x) for x in inp().split()] flag = False for i in range(2, n): if a[i] >= a[0] + a[1]: print(1, 2, i+1) flag = True break if not flag: 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; const int N = 5e4 + 5; long long a[N]; void solve() { long long n, i; cin >> n; for (i = 0; i < n; i++) cin >> a[i]; long long x, y, z; x = a[0]; y = a[1]; z = a[n - 1]; if (x + y <= z) { cout << "1 2 " << n << '\n'; return; } cout << "-1\n"; } int main() { int t; cin >> t; while (t--) 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
numCases=int(input()) cases=[] values=[] for i in range(numCases): cases.append(input()) values.append(list(map(int, input().split(" ")))) ret=[] for x in values: if (x[0]+x[1]>x[-1]): ret.append("-1") else: ret.append([1,2,x.index(x[-1])+1]) for i in ret: k=[] if(i!="-1"): for x in i: k.append(str(x)) print(" ".join(k)) 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(arr): ans = [] s = arr[0]+arr[1] if s <= arr[-1]: print(1,2,len(arr)) else: print(-1) t = int(input()) for i in range(t): input() solve(list(map(int, input().split())))
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
//package Competitive; import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws IOException{ String[] arr= {"a"}; code3 obj=new code3(); obj.main(arr); } } class code3{ 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[] arr=new int[n]; for(int i=0;i<n;i++) { arr[i]=sc.nextInt(); } if(arr[0]+arr[1]>arr[n-1]) { System.out.println(-1); } else System.out.println(1+" "+2+" "+n); } } } class Reader{ BufferedReader reader; Reader(){ reader=new BufferedReader(new InputStreamReader(System.in)); } int nextInt() throws IOException{ String in=reader.readLine().trim(); return Integer.parseInt(in); } long nextLong() throws IOException{ String in=reader.readLine().trim(); return Long.parseLong(in); } String next() throws IOException{ return reader.readLine().trim(); } String[] stringArray() throws IOException{ return reader.readLine().trim().split("\\s+"); } int[] intArray() throws IOException{ String[] inp=this.stringArray(); int[] arr=new int[inp.length]; int i=0; for(String s:inp) { arr[i++]=Integer.parseInt(s); } 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t-- > 0) { int n; cin >> n; vector<int> a(n); for (int& v : a) cin >> v; if (a[0] + a[1] > a[n - 1]) cout << "-1\n"; else cout << "1 2 " << n << '\n'; } 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
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
from sys import stdin,stdout # stdin = open("input.txt","r") # stdout = open("output.txt","w") t = int(stdin.readline().strip()) for _ in range(t): n = int(stdin.readline().strip()) narr = list(map(int,stdin.readline().strip().split(' '))) if n==3: arr=narr if arr[0]+arr[1]<=arr[2]: stdout.write(str(1)+" "+str(2)+" "+str(3)+"\n") else: stdout.write("-1\n") else: arr=[narr[0],narr[1],narr[-1]] if arr[0]+arr[1]<=arr[2]: stdout.write(str(1)+" "+str(2)+" "+str(n)+"\n") else: stdout.write("-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
t=int(input()) for _ in range(t): n=int(input()) arr=input().split() for i in range(n): arr[i]=int(arr[i]) if arr[0]+arr[1]<=arr[-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
from bisect import bisect_left, bisect_right from itertools import combinations from itertools import permutations from bisect import bisect_left from math import ceil from math import radians from heapq import heapify, heappush, heappop import bisect from math import pi from collections import deque from math import factorial from math import log, ceil from collections import defaultdict from math import * from sys import stdin, stdout import itertools import os import sys import threading from collections import deque, Counter, OrderedDict, defaultdict from heapq import * # from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd # from bisect import bisect_left,bisect_right # from decimal import *,threading from fractions import Fraction mod = int(pow(10, 9)+7) # mod = 998244353 def ii(): return int(input()) def si(): return str(input()) def mi(): return map(int, input().split()) def li1(): return list(mi()) def fii(): return int(stdin.readline()) def fsi(): return str(stdin.readline()) def fmi(): return map(int, stdin.readline().split()) def fli(): return list(fmi()) abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25} def getKey(item): return item[0] def sort2(l): return sorted(l, key=getKey) def d2(n, m, num): return [[num for x in range(m)] for y in range(n)] def isPowerOfTwo(x): return (x and (not (x & (x - 1)))) def decimalToBinary(n): return bin(n).replace("0b", "") def ntl(n): return [int(i) for i in str(n)] def powerMod(x, y, p): res = 1 x %= p while y > 0: if y & 1: res = (res * x) % p y = y >> 1 x = (x * x) % p return res graph = defaultdict(list) visited = [0] * 1000000 col = [-1] * 1000000 def bfs(d, v): q = [] q.append(v) visited[v] = 1 while len(q) != 0: x = q[0] q.pop(0) for i in d[x]: if visited[i] != 1: visited[i] = 1 q.append(i) print(x) def make_graph(e): d = {} for i in range(e): x, y = mi() if x not in d: d[x] = [y] else: d[x].append(y) if y not in d: d[y] = [x] else: d[y].append(x) return d def gr2(n): d = defaultdict(list) for i in range(n): x, y = mi() d[x].append(y) return d def connected_components(graph): seen = set() def dfs(v): vs = set([v]) component = [] while vs: v = vs.pop() seen.add(v) vs |= set(graph[v]) - seen component.append(v) return component ans = [] for v in graph: if v not in seen: d = dfs(v) ans.append(d) return ans def primeFactors(n): s = set() while n % 2 == 0: s.add(2) n = n // 2 for i in range(3, int(sqrt(n)) + 1, 2): while n % i == 0 and i % 2 == 1: s.add(i) n = n // i if n > 2 and n % 2 == 1: s.add(n) return s def find_all(a_str, sub): start = 0 while True: start = a_str.find(sub, start) if start == -1: return yield start start += len(sub) def SieveOfEratosthenes(n, isPrime): isPrime[0] = isPrime[1] = False for i in range(2, n): isPrime[i] = True p = 2 while (p * p <= n): if (isPrime[p] == True): i = p * p while (i <= n): isPrime[i] = False i += p p += 1 return isPrime def dijkstra(edges, f, t): g = defaultdict(list) for l, r, c in edges: g[l].append((c, r)) q, seen, mins = [(0, f, ())], set(), {f: 0} while q: (cost, v1, path) = heappop(q) if v1 not in seen: seen.add(v1) path = (v1, path) if v1 == t: return (cost, path) for c, v2 in g.get(v1, ()): if v2 in seen: continue prev = mins.get(v2, None) next = cost + c if prev is None or next < prev: mins[v2] = next heappush(q, (next, v2, path)) return float("inf") def binsearch(a, l, r, x): while l <= r: mid = l + (r-1)//2 if a[mid]: return mid elif a[mid] > x: l = mid-1 else: r = mid+1 return -1 # def input(): # return stdin.buffer.readline() def readTree(n): adj = [set() for _ in range(n)] for _ in range(n-1): u, v = map(int, input().split()) adj[u-1].add(v-1) adj[v-1].add(u-1) return adj def treeOrderByDepth(n, adj, root=0): parent = [-2] + [-1]*(n-1) ordered = [] q = deque() q.append(root) depth = [0] * n while q: c = q.popleft() ordered.append(c) for a in adj[c]: if parent[a] == -1: parent[a] = c depth[a] = depth[c] + 1 q.append(a) return (ordered, parent, depth) def isSubSequence(str1, str2): m = len(str1) n = len(str2) j = 0 # Index of str1 i = 0 # Index of str2 # Traverse both str1 and str2 # Compare current character of str2 with # first unmatched character of str1 # If matched, then move ahead in str1 while j < m and i < n: if str1[j] == str2[i]: j = j+1 i = i + 1 # If all characters of str1 matched, then j is equal to m return j == m def nextPowerOf2(n): count = 0 # First n in the below # condition is for the # case where n is 0 if (n and not(n & (n - 1))): return n while(n != 0): n >>= 1 count += 1 return 1 << count def cou(n): c = 0 while n > 1: c += 1 n //= 2 return c def sortsec(l): return sorted(l, key=lambda x: x[1]) def BinarySearch(a, x): i = bisect_left(a, x) if i: return (i-1) else: return - 1 def subarray(A): r = set() p = {0} for x in A: p = {x | y for y in p} | {x} r |= p return len(r) for _ in range(ii()): n = ii() l = li1() 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 _ in range(t): n = int(input()) a = list(map(int,input().split())) find = False x = a[0] z = a[-1] for i in range(1,n-1): y = a[i] if x + y <= z: find = True break if find: print(1,i+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
import sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect from time import perf_counter from fractions import Fraction import copy # import numpy as np mod = int(pow(10, 9) + 7) mod2 = 998244353 def data(): return sys.stdin.readline().strip() def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end) def L(): return list(sp()) def sl(): return list(ssp()) def sp(): return map(int, data().split()) def ssp(): return map(str, data().split()) def l1d(n, val=0): return [val for i in range(n)] def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)] try: # sys.setrecursionlimit(int(pow(10,6))) sys.stdin = open("input.txt", "r") # sys.stdout = open("../output.txt", "w") except: pass for _ in range(L()[0]): n=L()[0] A=L() x=A[0] y=A[1] z=A[-1] if (x+y)<=z: 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.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class CodeChef { static int mod = (int)1e9+7; public static void main(String[] args) { Scanner sc = new Scanner(); Functions f = new Functions(); int testCase = sc.nextInt(); while(testCase-->0){ int n = sc.nextInt(); int[] arr = sc.setIntegerArray(n); int sum = arr[0]+arr[1]; int r = -1; for(int i=n-1;i>=0;i--){ if(sum<=arr[i]){ r=i+1; break; } } if(r==-1) System.out.println(r); else System.out.println("1 2 "+r); } } } class Scanner { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenizer(""); public String next(){ while (!st.hasMoreTokens()) try { st = new StringTokenizer(br.readLine()); }catch (IOException e){ e.printStackTrace(); } return st.nextToken(); } public int nextInt(){ return Integer.parseInt(next()); } public long nextLong(){ return Long.parseLong(next()); } public int[] setIntegerArray(int n){ int[] arr =new int[n]; for(int i=0;i<n;i++)arr[i] = nextInt(); return arr; } public long[] setLongArray(int n){ long[] arr =new long[n]; for(int i=0;i<n;i++)arr[i] = nextLong(); return arr; } } class Functions extends CodeChef{ public void sort(int[] a){ ArrayList<Integer> temp = new ArrayList<>(); for (int j : a) temp.add(j); Collections.sort(temp);; for(int i=0;i<a.length;i++)a[i] = temp.get(i); } public long factorial(int n){ long fact = 1L; for(int i=2;i<=n;i++)fact= (fact*i)%mod; return fact; } public void sortRev(int[] a){ sort(a); int left = 0; int right = a.length-1; while (left<right){ int temp =a[left]; a[left] = a[right]; a[right] = temp; left++; right--; } } }
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 from math import sqrt, gcd, ceil, log, floor from bisect import bisect, bisect_left from collections import defaultdict, Counter, deque from heapq import heapify, heappush, heappop input = sys.stdin.readline read = lambda: list(map(int, input().strip().split())) # sys.setrecursionlimit(200000) # MOD = 10**9 + 7 def main(): # ans_ = [] for _ in range(int(input())): n = int(input()); arr = read() if arr[0]+arr[1] <= arr[-1]: print(1, 2, n) else: print(-1) # ans_.append(str(ans)) # print(("\n").join(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
java
import java.util.Scanner; public class BadTraingle { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t =sc.nextInt(); while(t-->0) { int n = sc.nextInt(); long arr[] = new long[n]; for(int i=0 ; i<n ; i++) arr[i] = sc.nextLong(); int j=2; long sum = arr[0]+arr[1]; boolean b = false; while(j<n) { if(sum<=arr[j]) { b=true; break;} else j++; } j++; if(b) System.out.println("1 2 "+j); 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
for _ in range(int(input())): n=int(input()) arr=list(map(int,input().split())) if arr[0]+arr[1]<=arr[-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 _ in range(t): n = int(input()) a = list(map(int,input().split())) a.sort() 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
for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) i = 2 while(i < n): if(a[i] >= a[0]+a[1]): break i += 1 if i == n: print(-1) else: print(1,2,i+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
#Problem F Shreyansh from math import * t=int(input()) while t: t=t-1 #n,m=map(int,input().split()) n=int(input()) a=list(map(int,input().split())) s=a[0]+a[1] flag=1 for i in range(2,n): if s<=a[i]: print(1,2,i+1) flag=0 break if flag: 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() { int64_t cases, total, elements, i; cin >> cases; for (i = 0; i < cases; i++) { int flag = 0, val = 0; vector<int> x = {}; cin >> total; for (int j = 0; j < total; j++) { cin >> elements; x.push_back(elements); } for (int l = 1; l <= x.size() - 2; l++) { if (x[0] + x[l] <= x[x.size() - 1]) { flag = 1; val = l; break; } } if (flag == 0) { cout << -1 << endl; } else { cout << 1 << " " << val + 1 << " " << x.size() << 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
for _ in range(int(input())): n = int(input()) *a, = 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 sys from functools import lru_cache, cmp_to_key from heapq import merge, heapify, heappop, heappush # from math import * from collections import defaultdict as dd, deque, Counter as C from itertools import combinations as comb, permutations as perm from bisect import bisect_left as bl, bisect_right as br, bisect from time import perf_counter from fractions import Fraction import copy import time # import numpy as np starttime = time.time() # import numpy as np mod = int(pow(10, 9) + 7) mod2 = 998244353 def data(): return sys.stdin.readline().strip() def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end) def L(): return list(sp()) def sl(): return list(ssp()) def sp(): return map(int, data().split()) def ssp(): return map(str, data().split()) def l1d(n, val=0): return [val for i in range(n)] def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)] try: # sys.setrecursionlimit(int(pow(10,6))) sys.stdin = open("input.txt", "r") # sys.stdout = open("../output.txt", "w") except: pass for _ in range(L()[0]): n=L()[0] A=sorted(L()) if A[0]+A[1]<=A[-1]: print(1,2,n) else: print(-1) endtime = time.time() # print(f"Runtime of the program is {endtime - starttime}")
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; long long int isprime[1000001]; void sieve() { long long int i, j, k; isprime[0] = isprime[1] = 1; for (i = 2; i <= sqrt(1000000); i++) { if (!isprime[i]) { for (j = 2 * i; j <= 1000000; j += i) { isprime[j] = 1; } } } } long long int modInverse(long long int a, long long int m) { long long int m0 = m; long long int y = 0, x = 1; if (m == 1) return 0; while (a > 1) { long long int q = a / m; long long int t = m; m = a % m; a = t; t = y; y = x - q * y; x = t; } if (x < 0) x += m0; return x; } long long int mod(long long int x, long long int n) { if (n == 0) return 1; if (n % 2 == 0) { long long int y = mod(x, n / 2); return ((y % 1000000007) * (y % 1000000007)) % 1000000007; } else { return ((x % 1000000007) * (mod(x, (n - 1)) % 1000000007)) % 1000000007; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); ; long long int t; cin >> t; while (t--) { long long int n; cin >> n; long long int a[n], i; for (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
from fractions import Fraction from collections import defaultdict import math import os import sys from io import BytesIO, IOBase 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") #----------------------------------------Code Starts Here--------------------------------------------# t = int(input()) for _ in range(t): n = int(input()) l = list([int(x) for x in input().split()]) a = l[0] b = l[1] c = l[n-1] if(a+b <= c): 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; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) { int n; cin >> n; vector<int> 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; } }
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[n-1]<a[1]+a[0]: print('-1') else: for i in range(2, n): if a[i]>=a[0]+a[1]: print('1 2 '+str(i+1)) 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
for _ in range (int(input())): n=int(input()) a=list(map(int,input().split())) a1,a2,a3=a[0],a[1],a[-1] if a1+a2>a3: 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; scanf("%d", &t); while (t--) { int n; cin >> n; int a[n]; for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } if (a[0] + a[1] > a[n - 1]) { printf("-1"); printf("\n"); } else { printf("1"); printf(" "); printf("2"); printf(" "); printf("%d", n); printf("\n"); } } 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
tc = int(input()) for _ in range(tc): n = int(input()) arr = list(map(int, input().split())) A,B = arr[0], arr[1] f = 1 for i in range(2, n): C = arr[i] if(A+B <= C or B + C <= A or C + A <= B): print(1, 2, i+1) f = 0 break if(f): 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--) { long long int n; cin >> n; long long int ar[n + 1]; for (long long int i = 1; i <= n; i++) cin >> ar[i]; long long int x = ar[1], y = ar[2], z = ar[n]; if ((x + y) <= z || (y + z) <= x || (z + x) <= y) 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
t = int(input()) for _ in range(t): n = int(input()) lol=[int(n) for n in input().split()] z=lol.copy() z.sort() if(z[0] + z[1] <=z[-1]): #if(z[0]==z[1]): print(1,2,n) '''print(lol.index(z[0]),end=' ') lol.remove(z[0]) print(lol.index(z[1]),end=' ') print(lol.index(z[-1]),end=' ')''' 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()) ls=list(map(int,input().split())) ls.sort() if ls[0]+ls[1]<=ls[-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() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); int t; cin >> t; while (t--) { long long int n; long long int ar[50009]; cin >> n; for (int i = 1; i <= n; i++) { cin >> ar[i]; } if ((ar[1] + ar[2]) > ar[n]) { cout << "-1" << endl; } else cout << "1" << " " << "2" << " " << n << 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
import sys input=sys.stdin.buffer.readline #arr[i]+arr[j]!=arr[k] t=int(input()) for _ in range(t): n=int(input()) arr=[int(x) for x in input().split()] if arr[0]+arr[1]<=arr[n-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
def main(): for i in range(int(input())): n = int(input()) arr = list(map(int,input().split())) if arr[n-1]>=arr[0]+arr[1]: print('1 2 {}'.format(n)) else: print(-1) 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.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int n,f=0,i,j,s=0,k; n=sc.nextInt(); int a[]=new int[n]; for(i=0;i<n;i++) a[i]=sc.nextInt(); if(a[0]+a[1]>a[n-1]) System.out.println("-1"); else System.out.println("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 t in range(int(input())): num=int(input()) arr=list(map(int,input().split())) if arr[0]+arr[1]>arr[num-1]: print(-1) else: print(1,2,num)
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 test in range(0, t): n = int(input()) sides = list(map(int, input().split(' '))) if sides[0] + sides[1] <= sides[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; long long mod = 1e9 + 7; long long C(int n, int r) { if (r > n) return 0; if (r > n - r) r = n - r; long long ans = 1; int i; for (i = 1; i <= r; i++) { ans *= n - r + i; ans /= i; } return ans; } vector<long long> sieve(long long n) { vector<long long> is_prime(n + 1, true); is_prime[0] = is_prime[1] = false; for (int i = 2; i <= n; i++) { if (is_prime[i] && (long long)i * i <= n) { for (int j = i * i; j <= n; j += i) is_prime[j] = false; } } return is_prime; } void test() { long long n; cin >> n; vector<long long> v(n); for (long long(i) = 0; (i) < n; ++(i)) cin >> v[i]; long long i = 0, j = 1, k = n - 1; if (v[i] + v[j] <= v[k]) { cout << i + 1 << " " << j + 1 << " " << k + 1 << "\n"; return; } cout << "-1\n"; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); long long t = 1; cin >> t; for (long long T = 0; T < t; T++) { test(); } cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\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; void solve() { long long int n; long long int a[50007]; cin >> 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; } int main() { long long int t; cin >> t; for (int i = 0; i < t; i++) { 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()) for _ in range(t): n=int(input()) arr=list(map(int,input().split())) if arr[0]+arr[1]>arr[-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 _ in range(t): n = input() a = [int(x) for x in 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
for _ in range(int(input())): n = int(input()) a=list(map(int,input().split())) if a[0]+a[1]<=a[n-1]: print("1 2 ",n,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
import sys readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) T = ni() for _ in range(T): n = ni() a = nl() 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
for _ in range(int(input())): n=int(input()) l=list(map(int,input().split())) s=l[0]+l[1] flag=0 for i in range(2,n): if(s<=l[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
t = int(input()) for i in range(t): n = int(input()) pole = input().split() for j in range(n): pole[j] = int(pole[j]) hran = pole[0]+pole[1] pravda = False for j in range(n): if pole[j] >= hran: pravda = True break if pravda == True: print(1,2,j+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
t=int(input()) for i in range(t): n=int(input()) lst=list(map(int,input().split())) m=max(lst) index=lst.index(m) flag=0 lst.pop(index) for i in range(len(lst)-1): if(lst[i]+lst[i+1]<=m): print(i+1,i+2,index+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
java
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception { FastScanner sc = new FastScanner(System.in); PrintWriter pw = new PrintWriter(System.out); int t = sc.nextInt(); for(int ti = 0; ti < t; ti++){ int n = sc.nextInt(); long[] a = sc.nextLongArray(n); pw.println(a[0]+a[1] > a[n-1] ? "-1" : "1 2 "+n ); } pw.flush(); } static class GeekInteger { public static void save_sort(int[] array) { shuffle(array); Arrays.sort(array); } public static int[] shuffle(int[] array) { int n = array.length; Random random = new Random(); for (int i = 0, j; i < n; i++) { j = i + random.nextInt(n - i); int randomElement = array[j]; array[j] = array[i]; array[i] = randomElement; } return array; } } } class FastScanner { private BufferedReader reader = null; private StringTokenizer tokenizer = null; public FastScanner(InputStream in) { reader = new BufferedReader(new InputStreamReader(in)); tokenizer = null; } public String next() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { tokenizer = new StringTokenizer(reader.readLine()); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken(); } public String nextLine() { if (tokenizer == null || !tokenizer.hasMoreTokens()) { try { return reader.readLine(); } catch (IOException e) { throw new RuntimeException(e); } } return tokenizer.nextToken("\n"); } public long nextLong() { return Long.parseLong(next()); } public int nextInt() { return Integer.parseInt(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String[] nextArray(int n) { String[] a = new String[n]; for (int i = 0; i < n; i++) a[i] = next(); return a; } public int[] nextIntArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) a[i] = nextInt(); return a; } public long[] nextLongArray(int n) { long[] a = new long[n]; for (int i = 0; i < n; i++) a[i] = nextLong(); return 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
java
import java.io.*; import java.util.*; public class Solution extends PrintWriter { private void solve() { int t = sc.nextInt(); for(int tc = 1; tc <= t; tc++) { 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]) println(1 + " " + 2 + " " + n); else println(-1); } } // Solution() throws FileNotFoundException { super(new File("output.txt")); } // InputReader sc = new InputReader(new FileInputStream("test_input.txt")); Solution() { super(System.out); } InputReader sc = new InputReader(System.in); static class InputReader { InputReader(InputStream in) { this.in = in; } InputStream in; private byte[] buf = new byte[16384]; private int curChar; private int numChars; public int read() { if (numChars == -1) throw new InputMismatchException(); if (curChar >= numChars) { curChar = 0; try { numChars = in.read(buf); } catch (IOException e) { throw new InputMismatchException(); } if (numChars <= 0) return -1; } return buf[curChar++]; } public String nextLine() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isEndOfLine(c)); return res.toString(); } public String nextString() { int c = read(); while (isSpaceChar(c)) c = read(); StringBuilder res = new StringBuilder(); do { res.appendCodePoint(c); c = read(); } while (!isSpaceChar(c)); return res.toString(); } public long nextLong() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } long res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } public int nextInt() { int c = read(); while (isSpaceChar(c)) c = read(); int sgn = 1; if (c == '-') { sgn = -1; c = read(); } int res = 0; do { if (c < '0' || c > '9') throw new InputMismatchException(); res *= 10; res += c - '0'; c = read(); } while (!isSpaceChar(c)); return res * sgn; } private boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; } private boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; } } public static void main(String[] $) { new Thread(null, new Runnable() { public void run() { long start = System.nanoTime(); try {Solution solution = new Solution(); solution.solve(); solution.close();} catch (Exception e) {e.printStackTrace(); System.exit(1);} System.err.println((System.nanoTime()-start)/1E9); } }, "1", 1 << 27).start(); } }
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
//package ninetythree; import java.util.Scanner; public class A { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int tests = sc.nextInt(); for (int t = 0; t < tests; t++) { int n = sc.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } if (arr[n-1] >= arr[1] + arr[0]) { System.out.printf("%d %d %d\n", 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
cpp
#include <bits/stdc++.h> using namespace std; int main() { int t; cin >> t; while (t--) { int n, a[100000]; cin >> n; for (int i = 0; i < n; i++) cin >> a[i]; if (a[0] + a[1] <= a[n - 1]) { cout << 0 + 1 << " " << 1 + 1 << " " << n << "\n"; } 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
python3
# A. ΠŸΠ»ΠΎΡ…ΠΎΠΉ Ρ‚Ρ€Π΅ΡƒΠ³ΠΎΠ»ΡŒΠ½ΠΈΠΊ t = int(input()) arrays = [] for i in range(t): n = int(input()) a = list(map(int, input().split())) arrays.append(a) def func(arr: list): if arr[0] + arr[1] > arr[len(arr) - 1]: print(-1) return else: print(f'1 2 {len(arr)}') return # for i in range(len(arr)): # for j in range(i + 1, len(arr)): # sum = arr[i] + arr[j] # for k in range(len(arr) - 1, j, -1): # if sum <= arr[k]: # print(f'{i + 1} {j + 1} {k + 1}') # return # print(-1) for arr in arrays: func(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 t in range(int(input())): n = int(input()) l = list(map(int, input().split())) 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
# cook your dish here t=int(input()) for _ in range(t): n=int(input()) a=list(map(int,input().split())) k=a[0] m=a[1] if a[n-1]>=k+m: 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 o in range(0,t): n = int(input()) arr = list(map(int,input().split(" "))) sum = arr[0] + arr[1] flag = 0 for i in range(2,n): if(arr[i] >= sum): print("{} {} {}".format(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
t = int(input()) while t > 0: n = int(input()) lst = list(map(int, input().split())) if lst[0] + lst[1] <= lst[-1]: print(1,2,n) else: print(-1) 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, math input = lambda: sys.stdin.readline().rstrip() def pr(a, b, c): if a + b > c and a + c > b and c + b > a: return True return False for i in range(int(input())): n = int(input()) a = list(map(int, input().split())) f, t = a[0], a[1] ans = True for i in range(2, n): if not pr(f, t, a[i]): ans = False print(1, 2, i + 1) break if ans: 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
/* _oo0oo_ o8888888o 88" . "88 (| -_- |) 0\ = /0 ___/`---'\___ .' \\| |// '. / \\||| : |||// \ / _||||| -:- |||||- \ | | \\\ - /// | | | \_| ''\---/'' |_/ | \ .-\__ '-' ___/-. / ___'. .' /--.--\ `. .'___ ."" '< `.___\_<|>_/___.' >' "". | | : `- \`.;`\ _ /`;.`/ - ` : | | \ \ `_. \_ __\ /__ _/ .-` / / =====`-.____`.___ \_____/___.-`___.-'===== `=---=' */ import java.util.function.Consumer; import java.util.*; import java.math.BigDecimal; import java.math.BigInteger; import java.math.RoundingMode; import java.text.DecimalFormat; import java.io.*; import java.lang.Math.*; public class KickStart2020{ static class FastReader { 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());} float nextFloat() {return Float.parseFloat(next());} String nextLine() { String str = ""; try {str = br.readLine();} catch (IOException e) { e.printStackTrace();} return str; }} static String reverseOfString(String a) { StringBuilder ssd = new StringBuilder(); for(int i = a.length() - 1; i >= 0; i--) { ssd.append(a.charAt(i)); } return ssd.toString(); } static char[] reverseOfChar(char a[]) { char b[] = new char[a.length]; int j = 0; for(int i = a.length - 1; i >= 0; i--) { b[i] = a[j]; j++; } return b; } static boolean isPalindrome(char a[]) { boolean hachu = true; for(int i = 0; i <= a.length / 2; i++) { if(a[i] != a[a.length - 1 - i]) { hachu = false; break; } } return hachu; } static long gcd(long a, long b) { if (b == 0) return a; return gcd(b, a % b); } static boolean check(String a) { boolean hachu = true; for(int i = 0; i < a.length(); i++) { if(a.charAt(0) != a.charAt(i)) {hachu = false; break;} } return hachu; } public static void main(String[] args) throws Exception{ FastReader sc = new FastReader(); PrintWriter out = new PrintWriter(System.out); 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(); long sum = arr[0] + arr[1]; int k = 0; boolean hachu = false; for(int i = n - 1; i > 1; i--) { if(arr[i] >= sum) {hachu = true; k = i; break;} } if(hachu) System.out.println(1 + " " + 2 + " " + " " + (k + 1)); else System.out.println(-1); } } }