solution stringlengths 11 983k | difficulty int64 0 21 | language stringclasses 2
values |
|---|---|---|
n,k=list(map(int,input().split()))
x=[]
y=[]
z=[]
for i in range(n):
t,a,b=list(map(int,input().split()))
if a==1 and b==1:
z.append(t)
elif a==0 and b==1:
y.append(t)
elif a==1 and b==0:
x.append(t)
x1=len(x)
y1=len(y)
z1=len(z)
if min(x1,y1)+z1<k:
print(-1)
else:
x... | 11 | PYTHON3 |
# SortedList copied from: https://github.com/grantjenks/python-sortedcontainers/blob/master/sortedcontainers/sortedlist.py
# Minified with pyminifier to fit codeforce char limit
from __future__ import print_function
import sys
import traceback
from bisect import bisect_left, bisect_right, insort
from itertools import c... | 11 | PYTHON3 |
n, k = list(map(int, input().split()))
both, ab, ba = [0], [0], [0]
for i in range(n):
t, a, b = list(map(int, input().split()))
if a == 1 and b == 1:
both.append(t)
elif a == 1:
ab.append(t)
elif b == 1:
ba.append(t)
both, ab, ba = sorted(both), sorted(ab), sorted(ba)
for i in range(1, len(both)):
both[i]... | 11 | PYTHON3 |
# e_part_2_att_1.py
#attempted after contest
import sys
def input():
return sys.stdin.readline().rstrip()
def input_split():
return [int(i) for i in input().split()]
def add_book():
global freqs, cf, cp
# cost_change = 0
while(True):
if cf < freqs[cp]:
cf += 1
return cp
else:
cp += 1
cf = 0
def... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const int N = 4e5 + 10, mod = 1e9 + 7;
int bitc[N], bit[N];
int n;
void add(int i, int va) {
for (; i < N; i += (i & -i)) {
bit[i] += va;
bitc[i] += (va < 0 ? -1 : 1);
}
}
long long getprefones(int va) {
int i = 0;
int cur = 0;
long long ret = 0;
for (in... | 11 | CPP |
# for _ in range(int(input())):
# n,x = map(int,input().split())
# arr = list(map(int,input().split()))
# # b = []
# # for i in range(n):
# # t = []
# # for j in range(n):
# # t.append(arr[i]+arr[j])
# # b.append(t)
# f = 0
# k = n
# while k>=1:
# # print(k)
# i = 0
# while i<k:
# # print(i)
# ... | 11 | PYTHON3 |
n, k = list(map(int, input().split()))
ar1 = []
ar2 = []
ar3 = []
for i in range(n):
ar = list(map(int, input().split()))
if ar[1] == 1 and ar[2] == 0:
ar1.append(ar)
elif ar[1] == 0 and ar[2] == 1:
ar2.append(ar)
elif ar[1] == ar[2] == 1:
ar3.append(ar)
ar1.sort()
ar2.sort()
ar... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
bool rev(long long x, long long y) { return x > y; }
void input_arr(long long a[], long long n) {
for (long long i = 0; i < n; i += 1) cin >> a[i];
}
bool sortbysec(const pair<long long, long long> &a,
const pair<long long, long long> &b) {
return a.secon... | 11 | CPP |
n,k=map(int,input().split())
a=0
b=0
alike=[]
blike=[]
bothlike=[]
for _ in range(n):
t,aa,bb=map(int,input().split())
if aa==1:
a+=1
if bb==1:
b+=1
if aa==1 and bb==0:
alike.append(t)
elif aa==0 and bb==1:
blike.append(t)
elif aa==1 and bb==1:
bothlike.ap... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int N = INT_MAX;
long long INF1 = 1e9 + 5;
long long INF2 = 1e18L + 5;
map<long long, long long> my;
int h[10005];
int main() {
int n, k;
cin >> n >> k;
int chk1 = 0, chk2 = 0;
int a, b, c;
vector<int> v1, v2, v3;
for (int i = 0; i < n; i++) {
cin >> a >> b ... | 11 | CPP |
import heapq
n, k = map(int, input().rstrip().split())
inn = []
inb = []
inc = []
for i in range(n):
a,b,c = map(int, input().rstrip().split())
if(b==0 and c==0):
continue
elif(b==1 and c==0):
inb.append(a)
elif(b==0 and c==1):
inc.append(a)
else:
inn.append(a)
heap... | 11 | PYTHON3 |
from collections import defaultdict
n,k=map(int,input().split())
d=defaultdict(lambda: [0,0])
la=[]
lb=[]
lboth=[]
ca,cb,cboth=0,0,0
for x in range(n):
t,a,b=map(int,input().split())
if a==1 and b==1:
lboth.append(t)
cboth+=1
elif a==1:
la.append(t)
ca+=1
d[t][0]+=1
... | 11 | PYTHON3 |
n, k = map(int, input().split())
both, f, s = [], [], []
for i in range(n):
t, x, y = map(int, input().split())
if x == 1 and y == 1:
both.append(t)
elif x == 1:
f.append(t)
elif y == 1:
s.append(t)
if min(len(f),len(s)) + len(both) < k:
print(-1)
else:
both = sorte... | 11 | PYTHON3 |
n, k = map(int, input().split())
both, alice, bob = [], [], []
for _ in range(n):
t, a, b = map(int, input().split())
if a == 1 and b == 1:
both.append(t)
elif a == 1 and b == 0:
alice.append(t)
elif a == 0 and b == 1:
bob.append(t)
both.sort(reverse=True)
alice.sort(r... | 11 | PYTHON3 |
n,k = map(int,input().split())
d = []
l = []
a = []
b = []
for _ in range(n):
p,q,r = map(int,input().split())
if q == r :
if q == 0:
d.append(p)
else:
l.append(p)
else:
if q == 0 and r == 1:
b.append(p)
else:
a.append(p)
#print... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void solve() {
int n, k;
cin >> n >> k;
vector<int> a, b, c;
for (int i = 0; i < n; i++) {
int x, y, z;
cin >> x >> y >> z;
if (y == 0 && z == 0)
continue;
else if (y == 1 && z == 0)
a.push_back(x);
else if (y == 0 && z == 1)
b.... | 11 | CPP |
from sys import *
from math import *
n,k= map(int, stdin.readline().split())
x,y,z=[],[],[]
for i in range(n):
t,a,b= map(int, stdin.readline().split())
if a and b :
z.append(t)
elif a:
x.append(t)
elif b:
y.append(t)
x.sort()
y.sort()
for i in range(min(len(x),len(y))):
z.ap... | 11 | PYTHON3 |
def answer(n,k,l):
l.sort(key=lambda x:x[0])
a=[]
b=[]
ab=[]
for i in range(n):
if l[i][1]==1 and l[i][2]==1:
ab.append(l[i][0])
elif l[i][1]==1:
a.append(l[i][0])
elif l[i][2]==1:
b.append(l[i][0])
mini=min(len(a),len(b))
if ... | 11 | PYTHON3 |
import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
# region fastio
BUFSIZE = 819... | 11 | PYTHON3 |
def next():
return [int(x) for x in input().split()]
class book:
def __init__(self, t, a, b):
self.t = t
self.a = a
self.b = b
if __name__ == '__main__':
n, k = next()
books = []
for _ in range(n):
t, a, b = next()
books.append(book(t, a, b))
oo = list(m... | 11 | PYTHON3 |
from sys import stdout
from collections import defaultdict
import math
'''t=int(input())
for _ in range(t):
#n=int(input())
n,k=map(int,input().split())
l=list(map(int,input().split()))
l.sort(reverse=True)'''
n,k=map(int,input().split())
l=list()
d=defaultdict(list)
for i in range(n):
a,b,c=map(int... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e16;
class segTree {
public:
vector<long long> t;
int n;
segTree(int n) {
t.resize(n * 2 + 5, 0);
this->n = n;
}
void build() {
for (int i = n - 1; i > 0; --i) t[i] = t[i << 1] + t[i << 1 | 1];
}
void update(int p, long long... | 11 | CPP |
#include <bits/stdc++.h>
using namespace std;
const int M = 998244353;
vector<int> both, al, bob;
int k;
int good(int cnt, int mi, int ma) {
if (cnt > mi && (both[cnt - 1] > al[k - cnt] + bob[k - cnt])) return -1;
if (cnt < ma && (both[cnt] < al[k - cnt - 1] + bob[k - cnt - 1])) return 1;
return 0;
}
int main() {... | 11 | CPP |
n,k=map(int,input().split())
l,l1,l2=[],[],[]
for i in range(n):
a,b,c=map(int,input().split())
if b==1 and c==1:
l.append(a)
elif b==1 and c==0:
l1.append(a)
elif b==0 and c==1:
l2.append(a)
l1.sort()
l2.sort()
for j in range(min(len(l1),len(l2))):
l.append(l1[j]+l2[j])
l.so... | 11 | PYTHON3 |
from sys import stdin
inp = lambda : stdin.readline().strip()
n, k = [int(x) for x in inp().split()]
b = []
for _ in range(n):
b.append([int(x) for x in inp().split()])
both = []
alice = []
bob = []
for i in b:
if i[1] == 1 and i[2] == 1:
both.append(i[0])
elif i[1] == 1:
alice.append(i[0... | 11 | PYTHON3 |
book, k = map(int, input().split())
both, bob, alice = dict(), dict(), dict()
for i in range(book):
time, x, y = map(int, input().split())
if x == 1 and y == 0:
alice[i] = time
elif x == 0 and y == 1:
bob[i] = time
elif x == 1 and y == 1:
both[i] = time
if len(both) + len(alice)... | 11 | PYTHON3 |
import sys
import functools
[n,k]=[int(i) for i in sys.stdin.readline().split()]
arr=[]
for x in range(n):
[t,a,b]=[int(j) for j in sys.stdin.readline().split()]
arr.append([t,a,b])
alice=0
bob=0
for g in range(n):
if(arr[g][1]==1):
alice+=1
if(arr[g][2]==1):
bob+=1
if(alice<k or bob<k):
print(-1)
else:
... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
const long long Mod = 1e5 + 7;
const int N = 2e6 + 5;
int arr[N];
int idx[4] = {0, 0, 0, 0};
vector<int> vec[4];
int take(int x) {
if (vec[x].size() <= idx[x]) return Mod;
return vec[x][idx[x]++];
}
int get(int x) {
if (vec[x].size() <= idx[x]) return Mod;
return ar... | 11 | CPP |
n, k = map(int,input().split())
ar11 = []
ar10 = []
ar01 = []
for i in range(n):
t,a,b = map(int, input().split())
if(a==1 and b==1):
ar11.append(t)
elif(a==1 and b==0):
ar10.append(t)
elif(a==0 and b==1):
ar01.append(t)
# print(ar11, ar10, ar01)
if(len(ar11) + min(len(ar10), l... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
template <typename T1, typename T2>
inline void chkmin(T1 &x, const T2 &y) {
if (x > y) x = y;
}
template <typename T1, typename T2>
inline void chkmax(T1 &x, const T2 &y) {
if (x < y) x = y;
... | 11 | CPP |
from sys import stdin
from collections import defaultdict as dd
from collections import deque as dq
import itertools as it
from math import sqrt, log, log2
from fractions import Fraction
n, k = map(int, input().split())
alike, blike = 0, 0
zero_one, one_zero, one_one, zero_zero = [], [], [], []
for i in range(n):
... | 11 | PYTHON3 |
n,k=map(int,input().split())
share=[]
alice=[]
bob=[]
for i in range(n):
t,a,b=map(int,input().split())
if a and b:
share.append(t)
elif a:
alice.append(t)
elif b:
bob.append(t)
share.sort()
cs=[0]
for i in share:cs.append(cs[-1]+i)
alice.sort()
ca=[0]
for i in alice:ca.append(ca[-1]+i)
bob.sort()
cb=[0]... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
inline int read() {
int x = 0;
char ch;
while (!isdigit(ch = getchar()))
;
x = ch - 48;
while (isdigit(ch = getchar())) x = x * 10 + ch - 48;
return x;
}
const int MAXN = 2e5 + 5;
int n, m, k;
vector<pair<int, int> > t[4], tmp;
vector<int> ans;
inline int ca... | 11 | CPP |
n, k = map(int, input().split())
a = []
b = []
both = []
for _ in range(n):
x, y, z = map(int, input().split())
if y == 1 and z == 1:
both.append(x)
elif y == 1:
a.append(x)
elif z == 1:
b.append(x)
a.sort()
b.sort()
for i in range(min(len(a), len(b))):
both.append(a[i]+b[i])... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int n, k;
cin >> n >> k;
multiset<int> v, v0, v1;
for (int i = 0; i < n; i++) {
int t, a, b;
cin >> t >> a >> b;
if (a == 0 && b == 0) continue;
if (a == 0 && b == 1) {
v1.insert(t);
}
if (a == 1 && b == 0) v0.insert(t);
... | 11 | CPP |
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
long long ii = 1;
void solve() {
long long n;
long long kk;
cin >> n >> kk;
vector<long long> alice;
vector<long long> bob;
vector<long long> all;
long long al = 0;
long long bo = 0;
for (long long i = 0; i < n; i++) {
long lon... | 11 | CPP |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<long long> a;
vector<long long> b;
vector<long long> m;
for (long long i = 0; i < n; i = i + 1) {
long long t, aa, bb;
cin >> t >> aa >> bb;
if (aa == 1 && bb == 0) {
a.push_back(t);
}
... | 11 | CPP |
# stdin = open("testdata.txt")
# def input():
# return stdin.readline().strip()
def addition(lst,k):
lst_alice = []
lst_bob = []
lst_both = []
addition_lst = []
lst.sort()
for i in range(len(lst)):
if lst[i][1] == 1 and lst[i][2] == 0:
lst_alice.append(lst[i])
el... | 11 | PYTHON3 |
n,k = map(int, input().split())
a,b,ab = [],[],[]
for _ in range(n):
t,x,y = map(int, input().split())
if x==1 and y==1: ab.append(t)
elif x==1 and y==0: a.append(t)
elif x==0 and y==1: b.append(t)
if len(ab)+min(len(a),len(b))<k: print(-1)
else:
cost, ind, tog = 0,0,0
a.sort()
b.sort()
... | 11 | PYTHON3 |
from collections import deque
n,k=list(map(int,input().split()))
p=[]
al=0
bob=0
ali=[]
c=[]
bobi=[]
for i in range(n):
t,a,b=list(map(int,input().split()))
p.append((t,a,b))
if a==1:
al+=1
if b==1:
bob+=1
if a==1 and b==0:
ali.append(t)
if a==0 and b==1:
bobi.app... | 11 | PYTHON3 |
import sys
input=sys.stdin.readline
n,k=list(map(int,input().split()))
c=[]
d=[]
e=[]
for i in range(n):
t,a,b=list(map(int,input().split()))
if a==1 and b==1:
c.append(t)
if a==0 and b==1:
d.append(t)
if a==1 and b==0:
e.append(t)
d.sort()
e.sort()
x=min(len(d),len(e))
for i in... | 11 | PYTHON3 |
from collections import deque
n,k=map(int,input().split())
s,s1,s2=deque(),deque(),deque()
while(n):
t,a,b=map(int,input().split())
if(a==1 and b==1):
s.append(t)
if(a==1 and b==0):
s1.append(t)
if(a==0 and b==1):
s2.append(t)
n-=1
s=deque(sorted(s))
s1=deque(sorted(s1))
s2=deque(sorted(s2))
x,y,t... | 11 | PYTHON3 |
ve1 = []
ve2 = []
ve3 = []
s = input()
n, k = map(int,s.split(' '))
num1 = 0
num2 = 0
for i in range(0,n):
s = input()
t, a, b = map(int, s.split(' '))
if(a & b):
ve3.append(t)
num1 = num1 + 1
num2 = num2 + 1
elif(a == 0 and b == 1):
ve2.append(t)
num2 = num2 + ... | 11 | PYTHON3 |
n,k=map(int,input().split())
at=[]
bt=[]
both=[]
f=0
for x in range(n):
t,a,b=map(int,input().split())
if a==1 and b==1:
both.append(t)
elif a==1:
at.append(t)
elif b==1:
bt.append(t)
at.sort()
bt.sort()
both.sort()
i=0
j=0
if len(at)+len(both)<k or len(bt)+len(both)<k:
f=-1
else:
for x in range(k):
if i>... | 11 | PYTHON3 |
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
n, k = map(int, input().split())
alice, bob, together = [], [], []
for _ in range(n):
t, a, b = map(int, input().split())
if a and b:
together += t,
elif a:
alice += t,
elif b:
bob += t,
sa, sb, st = len(al... | 11 | PYTHON3 |
n, k = map(int, input().split())
combine = []
alice = []
bob = []
ha = 0
haa = 0
for i in range(n):
a = list(map(int, input().strip().split()))
if (a[1] == 1 and a[2] == 0):
alice.append(a[0])
ha += 1
elif (a[1] == 0 and a[2] == 1):
bob.append(a[0])
haa += 1
elif (a[1] ==... | 11 | PYTHON3 |
#include <CodeforcesSolutions.h>
#include <ONLINE_JUDGE <solution.cf(contestID = "1373",problemID = "B",method = "GET")>.h>
"""
Author : thekushalghosh
Team : CodeDiggers
I prefer Python language over the C++ language :p :D
Visit my website : thekushalghosh.github.io
"""
import sys,math,cma... | 11 | PYTHON3 |
# reading_books.py
from collections import defaultdict
n,k = map(int,input().split())
my_dick = {}
my_dick = defaultdict(lambda:list(),my_dick)
for i in range(n):
a,b,c = map(int,input().split())
if b+c==2:
my_dick[b+c].append(a)
elif b==0 and c == 1:
my_dick[b+3].append(a)
elif c==0 and b == 1:
my_dick[c+4].... | 11 | PYTHON3 |
import sys
input = sys.stdin.readline
n,minn = map(int,input().split())
a = []
ca, cb = 0, 0
for i in range(n):
t,x,y = map(int,input().split())
if x==1:
ca += 1
if y==1:
cb += 1
a.append((t,x,y))
if ca<minn or cb<minn:
print (-1)
exit()
ca,cb = 0,0
alice = []
bob = []
both = []
for i in range(n):
if a[i][1]... | 11 | PYTHON3 |
n,k=map(int,input().split())
a,b,c=[],[],[]
for i in range(n):
t,x,y=map(int,input().split())
if x==y==1:c.append(t)
elif x==1:a.append(t)
elif y==1:b.append(t)
a.sort();b.sort()
for i in range(min(len(a),len(b))):
c.append(a[i]+b[i])
c.sort()
if len(c)<k:print(-1)
else:print(sum(c[:k])) | 11 | PYTHON3 |
a,k = map(int,input().split())
l1=[]
l2=[]
l3=[]
for i in range(a):
b,c,d = map(int,input().split())
if(c==1 and d==1):
l3.append(b)
elif(c==1):
l1.append(b)
elif(d==1):
l2.append(b)
l1 = sorted(l1)
l2 = sorted(l2)
l3 = sorted(l3)
if((len(l1)+len(l3))<k or (len(l2)+len(l3))<k):
... | 11 | PYTHON3 |
n, k = map(int, input().split())
lForE = []
lForA = []
lForB = []
cnt = 0
forE = 0
forP = 0
ans = 0
for i in range(n):
temp = list(map(int, input().split()))
if temp[1] and temp[2]:
lForE.append(temp[0])
elif temp[1] and not temp[2]:
lForA.append(temp[0])
elif not temp[1] and temp[2]:
... | 11 | PYTHON3 |
"""
// Author : snape_here - Susanta Mukherjee
"""
from __future__ import division, print_function
import os,sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
def ii(): return int(in... | 11 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long n, k;
cin >> n >> k;
vector<tuple<long long, long long, long long>> v;
long long x = 0, y = 0, z = 0;
for (long long i = 0; i < n; i++) {
long long a, b, c;
cin >> a >> b >> c;
v.push_back(make_tuple(a, b, c));
if (b == 1 && ... | 11 | CPP |
z=input
mod = 10**9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
def lcd(xnum1,xnum2):
return (xnum1*xnum2//gcd(x... | 11 | PYTHON3 |
t=int(input())
for z in range(t):
n=int(input())
arr=list(map(int,input().split()))
min= arr[0] + arr[1]
pos=True
for i in range(2,n):
if(arr[i]>=min):
pos=False
posf=i
break
if(pos):
print("-1")
else:
print("1 2", posf+1)
| 7 | PYTHON3 |
t=int(input())
for _ in range(t):
n=int(input())
a=list(map(int,input().split()))
f=0
for i in range(2,len(a)):
if a[0]+a[1]<=a[i]:
f=1
print("1 2",i+1)
break
if f==0:
print(-1)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int tt;
cin >> tt;
while (tt--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
if (a[0] + a[1] <= a.back()) {
cout << "1 2 " << n << '\n';
... | 7 | CPP |
for t in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
c=0
for i in range(2,n):
l = i
r =n-1
if a[0]+a[1]<=a[l]:
c+=1
print(1,2,i+1)
break
if c==0:
print(-1)
| 7 | PYTHON3 |
# Pratyaydeep
import sys
inp=sys.stdin.buffer.read().split(b"\n");_ii=-1
_DEBUG=0
def debug(*args):
if _DEBUG:
import inspect
frame = inspect.currentframe()
frame = inspect.getouterframes(frame)[1]
string = inspect.getframeinfo(frame[0]).code_context[0].strip()
arns = string[... | 7 | PYTHON3 |
import sys
input = sys.stdin.buffer.readline
t = int(input())
for _ in range(t):
res = 0
n = int(input())
A = list(map(int, input().split()))
flag = 0
a,b,c=A[0],A[1],A[-1]
if c>=a+b:
print(1,2,n)
flag=1
if not flag:
a,b,c=A[0],A[-2],A[-1]
if c-b>=a:
... | 7 | PYTHON3 |
t = int(input())
while t > 0:
n = int(input())
# s = input()
# n, m = map(int, input().split())
a = list(map(int, input().split()))
# b = list(map(int, input().split()))
i = 0
k = n-1
j = -1
for it in range(1,n-1):
if a[i]+a[it]<=a[k]:
j = it
bre... | 7 | PYTHON3 |
t = int(input())
for _ in range(t):
n = int(input())
array = list(map(int, input().split()))
if array[0] + array[1] <= array[-1]:
print(1, 2, len(array))
else:
print(-1) | 7 | PYTHON3 |
# A. Bad Triangle
for _ in range(int(input())):
input()
a=list(map(int,input().split()))
if a[0]+a[1]<=a[-1]:
print(1,2,len(a))
else:
print(-1) | 7 | PYTHON3 |
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
if a[0] + a[1] > a[-1]:
print(-1)
else:
print(1, 2, len(a)) | 7 | PYTHON3 |
t=int(input())
for i in range(t):
n=int(input())
x=[int(x) for x in input().split()]
if x[0]+x[1]<=x[n-1]:
print(1, 2, n)
else:
print(-1) | 7 | PYTHON3 |
t = int(input())
n = []
sides = []
for _ in range(t):
n.append(int(input()))
sides.append(list(map(int, input().split())))
for te in range(t):
found = 0
if sides[te][0] + sides[te][1] <= sides[te][n[te]-1]:
print(1, 2, n[te])
found = 1
if not found:
print(-1)
| 7 | PYTHON3 |
#code
import bisect
for _ in range(int(input())):
n=int(input())
a=[int(s) for s in input().split()]
i=0
j=0
f=0
while(i<n-1):
s=a[i]+a[i+1]
j=bisect.bisect_left(a,s)
if j<n:
f=1
break
i+=1
if f:
print(i+1,i+2,j+1)
else... | 7 | PYTHON3 |
z,zz=input,lambda:list(map(int,z().split()));
szz,dgraphs,mod=lambda:sorted(zz()),{},10**9+7
from string import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter ... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
long long t, n;
long long arr[1000000];
cin >> t;
for (int a = 1; a <= t; a++) {
cin >> n;
for (int i = 0; i < n; i++) {
cin >> arr[i];
}
if (arr[0] + arr[1] <= arr[n - 1]) {
cout << 1 << " " << 2 << " " << n << "\n";
} e... | 7 | CPP |
t = int(input())
for i in range(t):
n = int(input())
a = list(map(int, input().split()))
if a[0] + a[1] > a[n-1]:
print(-1)
else:
print(1,2, n) | 7 | PYTHON3 |
#input template
from sys import stdin, stdout
from collections import Counter, OrderedDict
import math
cin = stdin.readline
cout = stdout.write
mp = lambda: list(map(int, cin().split()))
def chars(): #function for taking string input as character array since string in python is immutable
s = cin()
return(list(... | 7 | PYTHON3 |
from functools import reduce
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
input = lambda: sys.stdin.readline().rstrip("\r\n")
def value():return tuple(map(int,input().split()))
def arr():return [int(i) f... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long int;
ll binpow(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1) {
res = res * a;
}
a = a * a;
b >>= 1;
}
return res;
}
void solve() {
ll n;
cin >> n;
ll ar[n + 1];
for (ll i = 0; ... | 7 | CPP |
def main():
t = int(input())
for i 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)
if __name__ == "__main__":
main() | 7 | PYTHON3 |
import copy
import math
r = int(input())
for l in range(r):
n = int(input())
arr = [int(d) for d in input().split()]
if arr[0] + arr[1] <= arr[n-1]:
print(1, 2, n)
else:
print(-1)
| 7 | PYTHON3 |
def badtri(arr):
last=arr[-1]
for i in range(len(arr)-2):
diff=last-arr[i]
if arr[i+1]<=diff:
return (i+1,i+2,len(arr))
return (-1,)
t=int(input())
for i in range(t):
n=int(input())
arr=[int(k) for k in input().split()]
print(*badtri(arr)) | 7 | PYTHON3 |
#!/usr/local/bin/python3
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
a,b,c=arr[0],arr[1],arr[-1]
if a+b>c:
print(-1)
else:
print(1,2,n) | 7 | PYTHON3 |
def solve():
nb = int(input())
l = list(map(int, input().split()))
c = True
imi1, mi1 = l.index(min(l))+1, min(l)
l.remove(min(l))
imi2, mi2 = l.index(min(l))+2, min(l)
l.remove(min(l))
if max(l) >= mi1 + mi2:
res = [imi1, imi2, l.index(max(l))+3]
res.sort()
print(res[0], res[1], res[2])
c = False
i... | 7 | PYTHON3 |
import sys
inp=sys.stdin.buffer.read().split(b"\n");_ii=-1
def debug(*args):
import inspect
frame = inspect.currentframe()
frame = inspect.getouterframes(frame)[1]
string = inspect.getframeinfo(frame[0]).code_context[0].strip()
arns = string[string.find('(') + 1:-1].split(',')
print(' #debug:... | 7 | PYTHON3 |
# @author
import sys
class ABadTriangle:
def solve(self, tc=0):
for _ in range(int(input())):
n = int(input())
a = [int(_) for _ in input().split()]
u, v, w = a[0], a[1], a[-1]
if u + v <= w:
print(1, 2, n)
else:
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
bool cmp(int a, int b) { return a > b; }
int main() {
int t, n, a, b, c, d;
cin >> t;
while (t--) {
cin >> n;
for (int i = 0; i < n; i++) {
if (i == 0)
scanf("%d", &a);
else if (i == 1) {
scanf("%d", &b);
} else if (i == (n - ... | 7 | CPP |
for t in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
c=0
d=0
for i in range(2,n):
if(a[0]+a[1]<=a[i]):
c=1
d=i
break
if(c==1):
print(1,2,d+1)
else:
print(-1) | 7 | 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) | 7 | PYTHON3 |
# Bad Triangle
t = int(input())
for i in range(0,t):
n = int(input()); a = [ ]*n
a = [int(x) for x in input().split()]
if a[0]+a[1] <= a[len(a)-1]:
print(f"1 2 {len(a)}")
else:
print("-1") | 7 | PYTHON3 |
cases = int(input())
for x in range(cases):
input()
l = input().split(' ')
if len(l) >= 3 and int(l[0]) + int(l[1]) <= int(l[-1]):
print('1 2',len(l))
else:
print(-1) | 7 | PYTHON3 |
def main():
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)
main() | 7 | 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) | 7 | PYTHON3 |
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
if a[0]+a[1]<=a[n-1] or a[0]+a[n-1]<=a[1] or a[1]+a[n-1]<=a[0]:
print(1,2,n)
else:
print("-1") | 7 | PYTHON3 |
a = int(input())
i = 0
while i < a :
b = int(input())
c = input().split(" ")
d = []
s = 0
while s < b :
d.append(int(c[s]))
s = s + 1
s = 0
k = d
k.sort()
o = 0
l = 0
r = 0
while s < b :
if d[s] == k[0] :
s = s + 1
o = s
... | 7 | PYTHON3 |
import sys
T = int(sys.stdin.readline())
for _ in range(T):
N = int(sys.stdin.readline())
list_num = list(map(int, sys.stdin.readline().split()))
if list_num[-1] >= list_num[0] + list_num[1]:
print(1, 2, N)
else:
print(-1) | 7 | PYTHON3 |
for i in range(int(input())):
largo = int(input())
lista = [int(j) for j in input().split()]
solved = 0
minimo = lista[0]
maximo = lista[largo - 1]
for x in range(1, largo - 1):
if lista[x] + minimo <= maximo:
print(1, x + 1, largo)
solved = 1
break
... | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> vc(n);
for (int i = 0; i < n; i++) {
cin >> vc[i];
}
int i;
int count = 0;
for (i = 0; i < n - 2; i++) {
if (vc[i] + vc[i + 1] <= vc[n - 1]) {
... | 7 | CPP |
def A():
n = int(input())
arr = list(map(int, input().split()))
x = arr[0] + arr[1]
ans = []
if arr[-1] >= x:
ans.append(1)
ans.append(2)
ans.append(n)
return ans
return ans
if __name__ == '__main__':
t = int(input())
for i in range(t):
ans = A()... | 7 | PYTHON3 |
import sys
input = sys.stdin.readline
t=int(input())
for tests in range(t):
n=int(input())
A=list(map(int,input().split()))
if A[0]+A[1]<=A[n-1]:
print(1,2,n)
else:
print(-1)
| 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
void IO() {}
int ar[50005];
char ch[50005];
int m, n, k, ii;
void solve() {
scanf("%d", &n);
vector<pair<int, int>> v;
for (int i = 1; i <= n; i++) {
scanf("%d", &ar[i]);
v.push_back({ar[i], i});
}
sort(v.begin(), v.end());
if (v[0].first + v[1].first <=... | 7 | CPP |
##########################################################
from collections import Counter
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
import heapq
# c=sorted((i,int(val))for i,val in enumerate(input().split()))
# n = int(input())
# ls = list(map(int, input().split()))
# n, k = map(int, input().spl... | 7 | PYTHON3 |
for _ in range(int(input())):
n=int(input())
a =list(map(int,input().split()))
x,y,z=a[0],a[1],a[n-1]
if(x+y >z):
print(-1)
else:
print(1,2,n) | 7 | PYTHON3 |
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> v(n);
for (auto &i : v) cin >> i;
if (v[0] + v[1] > v[n - 1])
cout << "-1\n";
else
cout << 1 << " " << 2 << " " << n <... | 7 | CPP |
t = int(input())
for _ in range(t):
n = int(input())
l = [int(x) for x in input().split()]
a =l[0]
b = l[1]
c = l[-1]
if a+b > c:
print(-1)
else:
print(1, 2, n) | 7 | PYTHON3 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.