message stringlengths 2 65.1k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 0 108k | cluster float64 14 14 | __index_level_0__ int64 0 217k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,619 | 14 | 115,238 |
Tags: implementation
Correct Solution:
```
entrada1 = list(map(int,input().split()))
entrada2 = list(map(int,input().split()))
sum = 0
for i in range(1,entrada1[0]+1):
sum = sum + i
if(sum >= entrada1[1]):
sum = i - (sum - entrada1[1])
print(entrada2[sum-1])
break
... | output | 1 | 57,619 | 14 | 115,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,620 | 14 | 115,240 |
Tags: implementation
Correct Solution:
```
import math
import os
import random
import re
import sys
import functools
from operator import itemgetter, attrgetter
from collections import Counter
if __name__ == '__main__':
Y = lambda: list(map(int, input().split()))
P = lambda: map(int, input().split())
n, k... | output | 1 | 57,620 | 14 | 115,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,621 | 14 | 115,242 |
Tags: implementation
Correct Solution:
```
list1 = list(map(int, input().split()))
n = list1[0]
k = list1[1]
robotsSequence = list(map(int, input().split()))
def my_function(n, k, robotsSequence):
for i in range(1, n + 1, 1):
length = i*(i + 1) / 2
if(length >= k):
retreat = length - k... | output | 1 | 57,621 | 14 | 115,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,622 | 14 | 115,244 |
Tags: implementation
Correct Solution:
```
n, k = input().split()
n = int(n)
k = int(k)
a = list(map(int, input().split()))
for i in range(1, n+1):
res = (1 + i) * i // 2
if res >= k:
k = k - (i - 1) * i // 2
print(a[k-1])
break
``` | output | 1 | 57,622 | 14 | 115,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,623 | 14 | 115,246 |
Tags: implementation
Correct Solution:
```
n,k=[int(x) for x in input().split()]
s=[int(x) for x in input().split()]
i=0
while (((i+1)*(i+2))//2)<k:
i+=1
k-=(((i+1)*(i))//2)
print(s[k-1])
``` | output | 1 | 57,623 | 14 | 115,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,624 | 14 | 115,248 |
Tags: implementation
Correct Solution:
```
n, k = map(int, input().split())
ids = input().split()
F = [0, 1]
i = 1
while F[i] < k:
i += 1
F.append(F[i-1] + i)
print(ids[i-1 - (F[i] - k)])
``` | output | 1 | 57,624 | 14 | 115,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,625 | 14 | 115,250 |
Tags: implementation
Correct Solution:
```
n,k = map(int,input().split(" "))
a = list(map(int, input().split(" ")))
k -= 1
no = int(((8*k+1)**0.5 - 1)*0.5)
idx = k - int((no**2 + no)*0.5)
print(a[idx])
``` | output | 1 | 57,625 | 14 | 115,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snowball". Below there are the rules of this game. ... | instruction | 0 | 57,626 | 14 | 115,252 |
Tags: implementation
Correct Solution:
```
n,k= map(int,input().split())
a= list(map(int,input().split()))
i=1
while(i<k):
k-=i
i+=1
print(a[k-1])
``` | output | 1 | 57,626 | 14 | 115,253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,627 | 14 | 115,254 |
Yes | output | 1 | 57,627 | 14 | 115,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,628 | 14 | 115,256 |
Yes | output | 1 | 57,628 | 14 | 115,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,629 | 14 | 115,258 |
Yes | output | 1 | 57,629 | 14 | 115,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,630 | 14 | 115,260 |
Yes | output | 1 | 57,630 | 14 | 115,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,632 | 14 | 115,264 |
No | output | 1 | 57,632 | 14 | 115,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,633 | 14 | 115,266 |
No | output | 1 | 57,633 | 14 | 115,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
In late autumn evening n robots gathered in the cheerful company of friends. Each robot has a unique identifier — an integer from 1 to 109.
At some moment, robots decided to play the game "Snow... | instruction | 0 | 57,634 | 14 | 115,268 |
No | output | 1 | 57,634 | 14 | 115,269 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,693 | 14 | 115,386 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
read = lambda: map(int, input().split())
n, k, p = read()
a = list(read())
b = list(read())
a.sort()
b.sort()
def cal(a, b):
return abs(a - b) + abs(b - p)
mi = 1e15
for _ in range(k - n + 1):
ma = 0
for __ in range(n):
... | output | 1 | 57,693 | 14 | 115,387 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,694 | 14 | 115,388 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
def good(n, k, p, a, b, x):
j = 0
c = 0
for i in range(n):
while j < k:
if abs(a[i] - b[j]) + abs(b[j] - p) <= x:
j += 1
c += 1
break
j += 1
return... | output | 1 | 57,694 | 14 | 115,389 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,695 | 14 | 115,390 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
n,k,p=map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
a.sort()
b.sort()
ans = 1000000000000000
ans = int(ans)
for i in range(k-n+1):
tmp = 0
for j in range(n):
tmp = max(tmp,abs(a... | output | 1 | 57,695 | 14 | 115,391 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,696 | 14 | 115,392 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
"""
http://codeforces.com/problemset/problem/830/A
2 4 50
20 100
60 10 40 80 should output 50
"""
_, _, office = [int(i) for i in input().split()]
people = sorted(int(i) for i in input().split())
keys = sorted(int(i) for i in input().split())
... | output | 1 | 57,696 | 14 | 115,393 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,697 | 14 | 115,394 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
# by the authority of GOD author: manhar singh sachdev #
import os,sys
from io import BytesIO, IOBase
def check(mid,a,b,n,k,p):
z = k-1
for i in range(n-1,-1,-1):
while z != -1 and abs(b[z]-a[i])+abs(b[z]-p) > mid:
... | output | 1 | 57,697 | 14 | 115,395 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,698 | 14 | 115,396 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
read = lambda: map(int, input().split())
n, k, p = read()
a, b = sorted(read()), sorted(read())
print(min(max(abs(b[i + d] - a[i]) + abs(b[i + d] - p) for i in range(n)) for d in range(k - n + 1)))
# Made By Mostafa_Khaled
``` | output | 1 | 57,698 | 14 | 115,397 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,699 | 14 | 115,398 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
from sys import stdin, stdout
n,k,p = [int(x) for x in stdin.readline().rstrip().split()]
a = [int(x) for x in stdin.readline().rstrip().split()]
a = sorted(a)
b = [int(x) for x in stdin.readline().rstrip().split()]
b = sorted(b)
ans = int(2e... | output | 1 | 57,699 | 14 | 115,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken ... | instruction | 0 | 57,700 | 14 | 115,400 |
Tags: binary search, brute force, dp, greedy, sortings
Correct Solution:
```
n,k,p = map(int,input().split(" "))
a = [int(x) for x in input().split(" ")]
b = [int(x) for x in input().split(" ")]
a.sort()
b.sort()
result = []
for i in range(k):
max_time = 0
if k - i < n:
break
for ind in range(n):
tem=0
tem += ... | output | 1 | 57,700 | 14 | 115,401 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,120 | 14 | 116,240 |
Tags: implementation
Correct Solution:
```
queries = int(input())
for i in range(0, queries):
number = int(input())
permutation = input()
permutation_1 = permutation.split(" ")
permutation_array = []
for i in permutation_1:
permutation_array.append(int(i))
new_array_c =[]
new_array_ac =[]
for i in range(0, n... | output | 1 | 58,120 | 14 | 116,241 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,121 | 14 | 116,242 |
Tags: implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
arr = [int(p) for p in input().split()]
ind = arr.index(1)
f = ind + 1
b = ind - 1
fs = [1]
bs = [1]
if f == len(arr):
f = 0
while arr[f] != 1:
if f == len(arr)-1:
fs.append(arr[f])
f = 0
continue
fs.... | output | 1 | 58,121 | 14 | 116,243 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,122 | 14 | 116,244 |
Tags: implementation
Correct Solution:
```
q = int(input())
for query in range(q):
n = int(input())
p = [int(x) for x in input().split(' ')]
i = p.index(1)
if p[i:] + p[:i] == [j for j in range(1, n + 1)]:
ans = 'YES'
elif p[:i+1][::-1] + p[n - 1:i:-1] == [j for j in range(1, n + 1)]:
... | output | 1 | 58,122 | 14 | 116,245 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,123 | 14 | 116,246 |
Tags: implementation
Correct Solution:
```
q = int(input())
for t in range(q):
n = int (input())
a = [int(x) for x in input().split()]
a = a*2
index = a.index(1)
ans = 'NO'
if a[index:index+n] == list(range(1,n+1)) :
ans = "YES"
index = a.index(n)
if a[index:index+n] == list(ra... | output | 1 | 58,123 | 14 | 116,247 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,124 | 14 | 116,248 |
Tags: implementation
Correct Solution:
```
import sys
q = int(sys.stdin.readline())
for _ in range(q):
n = int(sys.stdin.readline())
p = list(map(int, sys.stdin.readline().split()))
start = 0
for i in range(n):
if p[i] == 1:
start = i
jung = True
cnt = True
for j in ran... | output | 1 | 58,124 | 14 | 116,249 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,125 | 14 | 116,250 |
Tags: implementation
Correct Solution:
```
t=int(input())
for _ in range(t):
n=int(input())
a=[int(x) for x in input().split()]
b=0
c=0
for i in range(n-1):
if(abs(a[i+1]-a[i])==1):
b+=1
elif(abs(a[i+1]-a[i])==n-1):
c+=1
if((b==n-1 and c==0) or (b==n-2 and... | output | 1 | 58,125 | 14 | 116,251 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,126 | 14 | 116,252 |
Tags: implementation
Correct Solution:
```
def solve():
n = int(input())
arr = list(map(int, input().split()))
for i in range(1, n):
if abs(arr[i] - arr[i - 1]) != 1:
if abs(arr[-1] - arr[0]) != 1:
return "NO"
else:
i += 1
while... | output | 1 | 58,126 | 14 | 116,253 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a permutation).
Students want to start a round d... | instruction | 0 | 58,127 | 14 | 116,254 |
Tags: implementation
Correct Solution:
```
t = int(input())
for u in range(0, t):
n = int(input())
a = []
s = input()
for i in s.split():
a.append(int(i))
f = 1
for i in range(0, n):
if a[i] == 1:
j = i
for c in range(1, n + 1):
if c != a[j... | output | 1 | 58,127 | 14 | 116,255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,128 | 14 | 116,256 |
Yes | output | 1 | 58,128 | 14 | 116,257 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,129 | 14 | 116,258 |
Yes | output | 1 | 58,129 | 14 | 116,259 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,130 | 14 | 116,260 |
Yes | output | 1 | 58,130 | 14 | 116,261 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,131 | 14 | 116,262 |
Yes | output | 1 | 58,131 | 14 | 116,263 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,132 | 14 | 116,264 |
No | output | 1 | 58,132 | 14 | 116,265 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,133 | 14 | 116,266 |
No | output | 1 | 58,133 | 14 | 116,267 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,134 | 14 | 116,268 |
No | output | 1 | 58,134 | 14 | 116,269 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n students standing in a circle in some order. The index of the i-th student is p_i. It is guaranteed that all indices of students are distinct integers from 1 to n (i. e. they form a ... | instruction | 0 | 58,135 | 14 | 116,270 |
No | output | 1 | 58,135 | 14 | 116,271 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,221 | 14 | 116,442 |
Tags: constructive algorithms, greedy
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
arr = list(map(int,input().split()))
aux = [0 for i in range(n)]
for i in range(n):
if i>0 and arr[i] > arr[i-1]:
aux[i] = 1
if i<n-1 and arr[i] > arr[i+1]:
aux[i] = 1
m = max(arr)
ans = -1
... | output | 1 | 58,221 | 14 | 116,443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,222 | 14 | 116,444 |
Tags: constructive algorithms, greedy
Correct Solution:
```
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
t=int(input())
for i in range(t):
n=int(input())
a=lnii()
if len(set(a))==1:
print(-1)
continue
mv=max(a)
for i in rang... | output | 1 | 58,222 | 14 | 116,445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,223 | 14 | 116,446 |
Tags: constructive algorithms, greedy
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
m=max(l)
ml=[]
for i in range(n):
if(l[i]==m):
ml.append(i)
ans=-1
if(ml[0]!=0):
ans=ml[0]+1
else:
for i in ml:
... | output | 1 | 58,223 | 14 | 116,447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,224 | 14 | 116,448 |
Tags: constructive algorithms, greedy
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
a = list(map(int,input().split()))
n = max(a)
k = 0
for i in range(len(a)):
if a[i]==n:
if i==0:
if a[i+1]<n:
k+=1
br... | output | 1 | 58,224 | 14 | 116,449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,225 | 14 | 116,450 |
Tags: constructive algorithms, greedy
Correct Solution:
```
def main():
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
M = max(a)
occs = a.count(M)
if occs == n:
print(-1)
else:
if a[0] == M and a[1... | output | 1 | 58,225 | 14 | 116,451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,226 | 14 | 116,452 |
Tags: constructive algorithms, greedy
Correct Solution:
```
for t in range(int(input())):
n = int(input())
p = list(map(int, input().split()))
if len(set(p)) == 1:
print(-1)
continue
m = max(p)
index = p.index(m)
if index == 0 and p[1] == p[0]:
index += 1
while l... | output | 1 | 58,226 | 14 | 116,453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,227 | 14 | 116,454 |
Tags: constructive algorithms, greedy
Correct Solution:
```
t = int(input())
for i in range(t):
n = int(input())
l = list(map(int,input().split()))
m = max(l)
for j in range(n):
if l[j] == m:
b1 = False
b2 = False
if j >= 1:
if l[j-1] != m:
... | output | 1 | 58,227 | 14 | 116,455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n piranhas with sizes a_1, a_2, …, a_n in the aquarium. Piranhas are numbered from left to right in order they live in the aquarium.
Scientists of the Berland State University want to find if there is dominant piranha in the aquar... | instruction | 0 | 58,228 | 14 | 116,456 |
Tags: constructive algorithms, greedy
Correct Solution:
```
def get_dom(a, n):
mx = max(a)
for i in range(n):
if a[i] != mx:
for j in range(i, -1, -1):
if a[j] == mx:
return j + 1
for j in range(i, n):
if a[j] == mx:
... | output | 1 | 58,228 | 14 | 116,457 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. T... | instruction | 0 | 58,309 | 14 | 116,618 |
Tags: greedy
Correct Solution:
```
import sys,os,io,time,copy,math
from functools import lru_cache
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
def main():
#n=int(input())
#arr=list(map(int,input().split()))
n,m=map(int,input().split())
... | output | 1 | 58,309 | 14 | 116,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. T... | instruction | 0 | 58,310 | 14 | 116,620 |
Tags: greedy
Correct Solution:
```
import os.path
import sys
if os.path.exists('input.txt'):
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
n,m=[int(x) for x in input().split(' ')]
x=min(n,m)
#print(x)
if n<m:
ans=x*"GB"
else:
ans=x*'BG'
n=n-x
m=m-x
#print(n,m)
if n!=0:
ans+... | output | 1 | 58,310 | 14 | 116,621 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed f... | instruction | 0 | 58,311 | 14 | 116,622 |
No | output | 1 | 58,311 | 14 | 116,623 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.