message stringlengths 2 433k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 113 108k | cluster float64 12 12 | __index_level_0__ int64 226 217k |
|---|---|---|---|---|---|
Provide a correct Python 3 solution for this coding contest problem.
There are N integers written on a blackboard. The i-th integer is A_i.
Takahashi and Aoki will arrange these integers in a row, as follows:
* First, Takahashi will arrange the integers as he wishes.
* Then, Aoki will repeatedly swap two adjacent in... | instruction | 0 | 85,615 | 12 | 171,230 |
"Correct Solution:
```
import sys
sys.setrecursionlimit(1000000000)
def gcd(a: int, b:int):
while b:
a,b=b,a%b
return a
def merge(a,us,vs):
i,j,res=0,0,[]
while i<len(us) and j<len(vs):
if a[us[i]]>=a[vs[j]]:
res.append(us[i])
i+=1
else:
res.... | output | 1 | 85,615 | 12 | 171,231 |
Provide tags and a correct Python 2 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,775 | 12 | 171,550 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
from sys import stdin, stdout
from collections import Counter, defaultdict
from itertools import permutations, combinations
raw_input = stdin.readline
pr = stdout.write
mod=10**9+7
def ni():
return int(raw_input())
def li():
r... | output | 1 | 85,775 | 12 | 171,551 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,776 | 12 | 171,552 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
# 1208D
class segTree():
def __init__(self, n):
self.t = [0] * (n << 2)
def update(self, node, l, r, index, value):
if l == r:
self.t[node] = value
return
mid = (l + r) >> 1
... | output | 1 | 85,776 | 12 | 171,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,777 | 12 | 171,554 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
# https://codeforces.com/contest/1208/problem/D
from sys import stdin, stdout
input = stdin.readline
# print = stdout.write
# si is the sum of elements before the i-th element that are smaller than the i-th element.
# For every i from... | output | 1 | 85,777 | 12 | 171,555 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,778 | 12 | 171,556 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
class FTree:
def __init__(self, f):
self.n = len(f)
self.ft = [0] * (self.n + 1)
for i in range(1, self.n + 1):
self.ft[i] += f[i - 1]
if i + self.lsone(i) <= self.n:
... | output | 1 | 85,778 | 12 | 171,557 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,779 | 12 | 171,558 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
# https://codeforces.com/contest/1208/problem/D
from sys import stdin, stdout
input = stdin.readline
print = stdout.write
# For every i from N to 1, let's say the value of the si is x.
# So it means there are k smallest unused numbers... | output | 1 | 85,779 | 12 | 171,559 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,780 | 12 | 171,560 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
import sys
input = sys.stdin.readline
n=int(input())
A=list(map(int,input().split()))
BIT=[0]*(n+1)
def update(v,w):
while v<=n:
BIT[v]+=w
v+=(v&(-v))
def getvalue(v):
ANS=0
while v!=0:
ANS+=BIT[v]... | output | 1 | 85,780 | 12 | 171,561 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,781 | 12 | 171,562 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
# TAIWAN NUMBER ONE!!!!!!!!!!!!!!!!!!!
from sys import stdin, stdout
from collections import defaultdict
from collections import deque
import math
import copy
... | output | 1 | 85,781 | 12 | 171,563 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,782 | 12 | 171,564 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
from operator import add
class Stree:
def __init__(self, f, n, default, init_data):
self.ln = 2**(n-1).bit_length()
self.data = [default] * (self.ln * 2)
self.f = f
for i, d in init_data.items():
... | output | 1 | 85,782 | 12 | 171,565 |
Provide tags and a correct Python 3 solution for this coding contest problem.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,5] and [4,3,1,2]. The following arrays are not ... | instruction | 0 | 85,783 | 12 | 171,566 |
Tags: binary search, data structures, greedy, implementation
Correct Solution:
```
def update(x,val):
while x<=n:
BIT[x]+=val
x+=(x&-x)
def query(x):
s=0
while x>0:
s=(s+BIT[x])
x-=(x&-x)
return s
n=int(input())
BIT=[0]*(n+1)
for i in range(1,n+1):
update(i,i)
arr=lis... | output | 1 | 85,783 | 12 | 171,567 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,784 | 12 | 171,568 |
Yes | output | 1 | 85,784 | 12 | 171,569 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,785 | 12 | 171,570 |
Yes | output | 1 | 85,785 | 12 | 171,571 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,786 | 12 | 171,572 |
Yes | output | 1 | 85,786 | 12 | 171,573 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,787 | 12 | 171,574 |
Yes | output | 1 | 85,787 | 12 | 171,575 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,788 | 12 | 171,576 |
No | output | 1 | 85,788 | 12 | 171,577 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,789 | 12 | 171,578 |
No | output | 1 | 85,789 | 12 | 171,579 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,790 | 12 | 171,580 |
No | output | 1 | 85,790 | 12 | 171,581 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
An array of integers p_{1},p_{2}, …,p_{n} is called a permutation if it contains each number from 1 to n exactly once. For example, the following arrays are permutations: [3,1,2], [1], [1,2,3,4,... | instruction | 0 | 85,791 | 12 | 171,582 |
No | output | 1 | 85,791 | 12 | 171,583 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,792 | 12 | 171,584 |
Tags: data structures, greedy
Correct Solution:
```
n=int(input())
s=sorted([[v,-i] for i,v in enumerate(map(int,input().split()))])
for _ in range(int(input())):
k,i=map(int,input().split())
ans=sorted(s[-k:],key=lambda x:-x[1])
print(ans[i-1][0])
``` | output | 1 | 85,792 | 12 | 171,585 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,793 | 12 | 171,586 |
Tags: data structures, greedy
Correct Solution:
```
def main():
n = int(input())
a = list(enumerate(map(int, (input().split()))))
a.sort(key = lambda item: (item[1], -item[0]))
#print(a)
m = int(input())
for i in range(m):
k, pos = map(int, input().split())
s = a[-k:]
s =... | output | 1 | 85,793 | 12 | 171,587 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,794 | 12 | 171,588 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
a = [int(x) for x in input().split()]
a_sorted = sorted(a, reverse=True)
m = int(input())
for i in range(m):
k, pos = [int(x) for x in input().split()]
vals = a_sorted[0:k]
result = []
for val in a:
if val in vals:
... | output | 1 | 85,794 | 12 | 171,589 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,795 | 12 | 171,590 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
b = list(map(int,input().split()))
a = [[0] * 2 for i in range(n)]
for i in range(n):
a[i][0] = b[i]
a[i][1] = i
for i in range(n-1):
for j in range(n-i-1):
if a[j][0] > a[j+1][0]:
a[j], a[j+1] = a[j+1], a[j]
el... | output | 1 | 85,795 | 12 | 171,591 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,796 | 12 | 171,592 |
Tags: data structures, greedy
Correct Solution:
```
#Code by Sounak, IIESTS
#------------------------------warmup----------------------------
import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
from collections import defaultdict
from itertools import permutations
BUFSIZE ... | output | 1 | 85,796 | 12 | 171,593 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,797 | 12 | 171,594 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
a = [int(i) for i in input().split()]
b = sorted(a)
b.reverse()
m = int(input())
for _ in range(m):
k, pos = map(int, input().split())
x = 0
j = 0
d = dict()
ans = 0
for i in b[:k]:
d[i] = d.get(i, 0) + 1
while x !=... | output | 1 | 85,797 | 12 | 171,595 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,798 | 12 | 171,596 |
Tags: data structures, greedy
Correct Solution:
```
n = int(input())
line = list(map(int, input().split()))
m = int(input())
for _ in range(m):
k, pos = map(int, input().split())
lf = line[:]
while len(lf) > k:
j = -1
x = min(lf)
while j > -len(lf)-1:
if lf[j] == x:
... | output | 1 | 85,798 | 12 | 171,597 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,...,a_n] of length n. Its subsequence is obtained... | instruction | 0 | 85,799 | 12 | 171,598 |
Tags: data structures, greedy
Correct Solution:
```
def mergesort(l, r, arr, pos):
if r - l == 1:
return arr, pos
m = (l + r) // 2
arr, pos = mergesort(l, m, arr, pos)
arr, pos = mergesort(m, r, arr, pos)
c = [0 for i in range(r)]
d = [0 for i in range(r)]
poi_a = l
poi_b = m
... | output | 1 | 85,799 | 12 | 171,599 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,800 | 12 | 171,600 |
Yes | output | 1 | 85,800 | 12 | 171,601 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,801 | 12 | 171,602 |
Yes | output | 1 | 85,801 | 12 | 171,603 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,802 | 12 | 171,604 |
Yes | output | 1 | 85,802 | 12 | 171,605 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,803 | 12 | 171,606 |
Yes | output | 1 | 85,803 | 12 | 171,607 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,804 | 12 | 171,608 |
No | output | 1 | 85,804 | 12 | 171,609 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,805 | 12 | 171,610 |
No | output | 1 | 85,805 | 12 | 171,611 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,806 | 12 | 171,612 |
No | output | 1 | 85,806 | 12 | 171,613 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is the easier version of the problem. In this version 1 ≤ n, m ≤ 100. You can hack this problem only if you solve and lock both problems.
You are given a sequence of integers a=[a_1,a_2,..... | instruction | 0 | 85,807 | 12 | 171,614 |
No | output | 1 | 85,807 | 12 | 171,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, …, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should ... | instruction | 0 | 85,808 | 12 | 171,616 |
Tags: binary search, data structures
Correct Solution:
```
n = int(input())
a = [0] + list(map(int, input().split()))
pos, pb, ps = [[0] * (n + 1) for x in range(3)]
def add(bit, i, val):
while i <= n:
bit[i] += val
i += i & -i
def sum(bit, i):
res = 0
while i > 0:
res += bit[i]... | output | 1 | 85,808 | 12 | 171,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given a permutation p_1, p_2, …, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,2,…, k, in other words in the end there should ... | instruction | 0 | 85,809 | 12 | 171,618 |
Tags: binary search, data structures
Correct Solution:
```
from bisect import bisect_right, bisect_left
# instead of AVLTree
class BITbisect():
def __init__(self, InputProbNumbers):
# 座圧
self.ind_to_co = [-10**18]
self.co_to_ind = {}
for ind, num in enumerate(sorted(list(set(InputPro... | output | 1 | 85,809 | 12 | 171,619 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, …, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,... | instruction | 0 | 85,810 | 12 | 171,620 |
No | output | 1 | 85,810 | 12 | 171,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given a permutation p_1, p_2, …, p_n.
In one move you can swap two adjacent values.
You want to perform a minimum number of moves, such that in the end there will exist a subsegment 1,... | instruction | 0 | 85,811 | 12 | 171,622 |
No | output | 1 | 85,811 | 12 | 171,623 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,871 | 12 | 171,742 |
Tags: geometry, math
Correct Solution:
```
import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
from bisect import bisect_left as bl, bisect_right as br, insort
from heapq import heapify, heappush, heappop
from collections import defaultdict as dd, deque, Counter
#from itertools im... | output | 1 | 85,871 | 12 | 171,743 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,872 | 12 | 171,744 |
Tags: geometry, math
Correct Solution:
```
import sys
from os import path
if(path.exists('input.txt')):
sys.stdin = open("input.txt","r")
sys.stdout = open("output.txt","w")
def solve():
n = int(input().strip())
a = [int(i) for i in input().rstrip().split()]
if(a[-1] - a[0] - a[1]) >= 0 :
... | output | 1 | 85,872 | 12 | 171,745 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,873 | 12 | 171,746 |
Tags: geometry, math
Correct Solution:
```
t=int(input())
while(t):
n=int(input())
a=list(map(int,input().split()))
if n>2:
flag=0
for i in range(len(a)-2):
if(a[i]+a[i+1]>a[n-1]):
continue
else:
flag=1
print(i+1,end=" "... | output | 1 | 85,873 | 12 | 171,747 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,874 | 12 | 171,748 |
Tags: geometry, math
Correct Solution:
```
t = int(input())
for _ in range (t):
n = int(input())
A = list(map(int, input().split()))
if A[0]+A[1] <= A[-1]:
print (1, 2, n)
else:
print (-1)
``` | output | 1 | 85,874 | 12 | 171,749 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,875 | 12 | 171,750 |
Tags: geometry, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
if(a[0]+a[1]>a[-1]):
print("-1")
else:
print(1,2,n)
``` | output | 1 | 85,875 | 12 | 171,751 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,876 | 12 | 171,752 |
Tags: geometry, math
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input())
a=[int(v) for v in input().split()]
p=a[0]
q=a[1]
r=a[-1]
if p+q<=r:
print(1,2,n)
else:
print(-1)
``` | output | 1 | 85,876 | 12 | 171,753 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,877 | 12 | 171,754 |
Tags: geometry, math
Correct Solution:
```
def solve(n, a):
a, b, c = a[0], a[1], a[-1]
if a + b > c:
print(-1)
else:
print(1, 2, n)
return
def main():
inp = lambda: [int(x) for x in input().split()]
tc = int(input())
for _ in range(tc):
n, a = int(input()), inp()
... | output | 1 | 85,877 | 12 | 171,755 |
Provide tags and a correct Python 3 solution for this coding contest problem.
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 nonz... | instruction | 0 | 85,878 | 12 | 171,756 |
Tags: geometry, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
lst=list(map(int,input().split()))
if lst[0]+lst[1]<=lst[-1]:
print(1,2,n)
else:
print(-1)
``` | output | 1 | 85,878 | 12 | 171,757 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1... | instruction | 0 | 85,967 | 12 | 171,934 |
Tags: dp, math
Correct Solution:
```
def putin():
return map(int, input().split())
def sol():
n = int(input())
C = list(putin())
B = list(putin())
q = int(input())
x = int(input())
min_arr = [x]
min_part_sums = [x]
part_sums = [C[0]]
for i in range(1, n):
part_sums.appe... | output | 1 | 85,967 | 12 | 171,935 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1... | instruction | 0 | 85,968 | 12 | 171,936 |
Tags: dp, math
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input());C = [int(a) for a in input().split()];B = [int(a) for a in input().split()];Q = int(input());x = int(input());P = 10 ** 9 + 7;
dp = [[0] * 20100 for _ in range(N + 1)];dp[0][0] = 1;ans = 0;s = x;t = s
for i in... | output | 1 | 85,968 | 12 | 171,937 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1... | instruction | 0 | 85,969 | 12 | 171,938 |
Tags: dp, math
Correct Solution:
```
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) for a in input().split()]
B = [int(a) for a in input().split()]
Q = int(input())
x = int(input())
P = 10 ** 9 + 7
dp = [[0] * 20100 for _ in range(N + 1)]
dp[0][0] = 1
ans = 0
s = x
t = s
for i in... | output | 1 | 85,969 | 12 | 171,939 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is the easy version of the problem. The only difference is that in this version q = 1. You can make hacks only if both versions of the problem are solved.
There is a process that takes place on arrays a and b of length n and length n-1... | instruction | 0 | 85,970 | 12 | 171,940 |
Tags: dp, math
Correct Solution:
```
def solve():
MOD = 10**9+7
n = int(input())
c = list(map(int, input().split()))
b = [0] + list(map(int, input().split()))
q = int(input())
queries = list(map(int, input().split()))
maxans = 1
for c1 in c:
maxans = maxans * (c1+1) % MOD
ans... | output | 1 | 85,970 | 12 | 171,941 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.