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 tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 113 | 12 | 226 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
# 1201C Maximum Median
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
m = n // 2; a.sort()
fst = 1; lst = int(2e9)
while fst != lst:
mid = (fst + lst + 1) // 2
tmp = 0
for i in range(m, n):
if mid - a[... | output | 1 | 113 | 12 | 227 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 114 | 12 | 228 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
n,k=map(int,input().split())
arr=list(map(int,input().split()))
arr.sort()
mid=n//2
itr=1
tot=0
for i in range(mid+1,n):
if tot+(arr[i]-arr[i-1])*itr>k:
break
else:
tot+= (arr[i]-arr[i-1])*itr
itr+=1
final=arr[mid+itr-1]+... | output | 1 | 114 | 12 | 229 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 115 | 12 | 230 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collection... | output | 1 | 115 | 12 | 231 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 116 | 12 | 232 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
n, k = map(int, input().split())
arr = list(map(int, input().split()))
if n == 1:
print(arr[0]+k)
else:
res = 0
arr.sort()
a = arr[n//2:]
diff = []
for i in range(1,len(a)):
diff.append(a[i]-a[i-1])
l = 0
w... | output | 1 | 116 | 12 | 233 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 117 | 12 | 234 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
n,k = [int(i) for i in input().split(" ")]
a = [int(i) for i in input().split(" ")]
a.sort()
b = a[n//2:]
def p(m):
ans = 0
for s in b:
if m <= s:
break
else:
ans += m-s
return ans <= k
low = b[0]
hig... | output | 1 | 117 | 12 | 235 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 118 | 12 | 236 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
n,k = map(int,input().split())
A = [int(x) for x in input().split()]
A.sort()
median = A[n//2]
inf = 10**16
from collections import defaultdict as dd, deque
C = dd(int)
for x in A[n//2:]:
C[x] += 1
C[inf] = 123
nmedian = C[median]
S = sorted(C.i... | output | 1 | 118 | 12 | 237 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 119 | 12 | 238 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
p = [0] * (n // 2)
m = n // 2
ans = a[m]
s = 0
for i in range(m + 1, n):
p[i - m - 1] = (a[i] - a[i -1])
s += p[i - m - 1] * (i - m)
if (k < s):
for i in range(m... | output | 1 | 119 | 12 | 239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is, replace it with a_i + 1).
You want to mak... | instruction | 0 | 120 | 12 | 240 |
Tags: binary search, greedy, math, sortings
Correct Solution:
```
size, k = map(int, input().split())
array = sorted(list(map(int, input().split())))
median_pos = size//2
increase_pos = list()
dif = list()
for x in range(median_pos+1, size):
cur = array[x]
prev = array[x - 1]
if cur != prev:
incr... | output | 1 | 120 | 12 | 241 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 121 | 12 | 242 |
Yes | output | 1 | 121 | 12 | 243 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 122 | 12 | 244 |
Yes | output | 1 | 122 | 12 | 245 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 123 | 12 | 246 |
Yes | output | 1 | 123 | 12 | 247 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 124 | 12 | 248 |
Yes | output | 1 | 124 | 12 | 249 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 125 | 12 | 250 |
No | output | 1 | 125 | 12 | 251 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 126 | 12 | 252 |
No | output | 1 | 126 | 12 | 253 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 127 | 12 | 254 |
No | output | 1 | 127 | 12 | 255 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You are given an array a of n integers, where n is odd. You can make the following operation with it:
* Choose one of the elements of the array (for example a_i) and increase it by 1 (that is... | instruction | 0 | 128 | 12 | 256 |
No | output | 1 | 128 | 12 | 257 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 184 | 12 | 368 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
import io
import os
from bisect import bisect_right
from collections import Counter, defaultdict, deque
# https://raw.githubusercontent.com/cheran-senthil/PyRival/master/pyrival/data_structures/RangeQuery.py
class RangeQuery:
def __in... | output | 1 | 184 | 12 | 369 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 185 | 12 | 370 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
import io,os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
import heapq
T = int(input())
r = 1
while r<=T:
n = int(input())
arr = list(map(int,input().split()))
# arr = [1,2]*50000+[1,3,1,2]+[1,2]*49998
#... | output | 1 | 185 | 12 | 371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 186 | 12 | 372 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
import math
class RMQ:
def __init__(self, arr):
self.n = len(arr)
self.logn = int(math.log2(self.n)) + 1
self.arr = [0] + arr
self.Log = [0] * (self.n + 1)
self.Log[2] = 1
for i in range(... | output | 1 | 186 | 12 | 373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 187 | 12 | 374 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
import sys
from array import array # noqa: F401
import typing as Tp # noqa: F401
def input():
return sys.stdin.buffer.readline().decode('utf-8')
T = Tp.TypeVar('T')
class SegmentTree(Tp.Generic[T]):
__slots__ = ["size", "tr... | output | 1 | 187 | 12 | 375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 188 | 12 | 376 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
"""
Author - Satwik Tiwari .
24th NOV , 2020 - Tuesday
"""
#===============================================================================================
#importing some useful libraries.
from __future__ import division, print... | output | 1 | 188 | 12 | 377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 189 | 12 | 378 |
Tags: binary search, data structures, greedy, two pointers
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... | output | 1 | 189 | 12 | 379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 190 | 12 | 380 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
import sys
input = sys.stdin.readline
import bisect
t=int(input())
for tests in range(t):
n=int(input())
A=list(map(int,input().split()))
LEN = len(A)
Sparse_table = [A]
for i in range(LEN.bit_length()-1):
j ... | output | 1 | 190 | 12 | 381 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a consisting of n integers.
Let min(l, r) be the minimum value among a_l, a_{l + 1}, …, a_r and max(l, r) be the maximum value among a_l, a_{l + 1}, …, a_r.
Your task is to choose three positive (greater than 0) inte... | instruction | 0 | 191 | 12 | 382 |
Tags: binary search, data structures, greedy, two pointers
Correct Solution:
```
from collections import Counter, OrderedDict
def nint():
return int(input())
def nintA():
return [int(x) for x in input().split()]
def f():
nint()
A = nintA()
n = len(A)
m = max(A)
l,r,rr = 0,0,0
... | output | 1 | 191 | 12 | 383 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is an interactive problem.
Homer likes arrays a lot and he wants to play a game with you.
Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to find any index k (1 ≤ k ≤ n) which is a local m... | instruction | 0 | 200 | 12 | 400 |
Tags: binary search, interactive, ternary search
Correct Solution:
```
from collections import deque
from typing import List
from sys import stdout
class ContestParser:
"""Helper module to read/write
Commonly in programming competition input for a problem is given with space separated numbers and strings.
... | output | 1 | 200 | 12 | 401 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem.
Homer likes arrays a lot and he wants to play a game with you.
Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to ... | instruction | 0 | 201 | 12 | 402 |
No | output | 1 | 201 | 12 | 403 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem.
Homer likes arrays a lot and he wants to play a game with you.
Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to ... | instruction | 0 | 202 | 12 | 404 |
No | output | 1 | 202 | 12 | 405 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem.
Homer likes arrays a lot and he wants to play a game with you.
Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to ... | instruction | 0 | 203 | 12 | 406 |
No | output | 1 | 203 | 12 | 407 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is an interactive problem.
Homer likes arrays a lot and he wants to play a game with you.
Homer has hidden from you a permutation a_1, a_2, ..., a_n of integers 1 to n. You are asked to ... | instruction | 0 | 204 | 12 | 408 |
No | output | 1 | 204 | 12 | 409 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 221 | 12 | 442 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
t = int(input().strip())
for case in range(t):
n = int(input().strip())
nums = list(map(int, input().split()))
count = nums.count(min(nums))
print(len(nums) - count)
``` | output | 1 | 221 | 12 | 443 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 222 | 12 | 444 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
import sys
read=sys.stdin.buffer.read;readline=sys.stdin.buffer.readline;input=lambda:sys.stdin.readline().rstrip()
import bisect,string,math,time,functools,random,fractions
from bisect import*
from heapq import heappush,heappop,heapify
from collections ... | output | 1 | 222 | 12 | 445 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 223 | 12 | 446 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
arr=list(map(int,input().split()))
arr.sort()
print(n-arr.count(arr[0]))
``` | output | 1 | 223 | 12 | 447 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 224 | 12 | 448 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
for i in range(int(input())):
n=int(input())
a=list(map(int,input().split()))
print(n-a.count(min(a)))
``` | output | 1 | 224 | 12 | 449 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 225 | 12 | 450 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
a=int(input())
while a:
a=a-1
n=int(input())
x=list(map(int,input().split()))
p=list(set(x))
p.sort()
print(n-x.count(p[0]))
``` | output | 1 | 225 | 12 | 451 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 226 | 12 | 452 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
for _ in range(int(input())):
n = int(input())
a = list(map(int, input().split()))
mn = min(a)
print(n - a.count(mn))
``` | output | 1 | 226 | 12 | 453 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 227 | 12 | 454 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
from itertools import combinations, permutations, combinations_with_replacement, product
import itertools
from timeit import timeit
import timeit
import time
from time import time
from random import *
import random
import collections
import bisect
impor... | output | 1 | 227 | 12 | 455 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly larger than AVG, where AVG is the average of the n... | instruction | 0 | 228 | 12 | 456 |
Tags: constructive algorithms, greedy, math
Correct Solution:
```
def solve():
n = int(input())
arr = list(map(int, input().split()))
m = min(arr)
k = arr.count(m)
print(n - k)
t = int(input())
for _ in range(t):
solve()
``` | output | 1 | 228 | 12 | 457 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 229 | 12 | 458 |
Yes | output | 1 | 229 | 12 | 459 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 230 | 12 | 460 |
Yes | output | 1 | 230 | 12 | 461 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 231 | 12 | 462 |
Yes | output | 1 | 231 | 12 | 463 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 232 | 12 | 464 |
Yes | output | 1 | 232 | 12 | 465 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 233 | 12 | 466 |
No | output | 1 | 233 | 12 | 467 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 234 | 12 | 468 |
No | output | 1 | 234 | 12 | 469 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 235 | 12 | 470 |
No | output | 1 | 235 | 12 | 471 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Eshag has an array a consisting of n integers.
Eshag can perform the following operation any number of times: choose some subsequence of a and delete every element from it which is strictly lar... | instruction | 0 | 236 | 12 | 472 |
No | output | 1 | 236 | 12 | 473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a... | instruction | 0 | 806 | 12 | 1,612 |
Tags: constructive algorithms
Correct Solution:
```
import math
import sys
input = sys.stdin.readline
n = int(input())
a = [int(_) for _ in input().split()]
piv = -1
for i in range(n):
if a[i - 1] < a[i]:
piv = i
break
if min(a) == 0 and max(a) == 0:
print('YES')
print(' '.join(['1'] * n))
... | output | 1 | 806 | 12 | 1,613 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a... | instruction | 0 | 807 | 12 | 1,614 |
Tags: constructive algorithms
Correct Solution:
```
n = int(input())
b = list(map(int, input().split()))
m, M = min(b), max(b)
if m == M:
if M == 0:
print('YES')
print(' '.join(['1' for i in range(n)]))
else:
print('NO')
else:
print('YES')
pos = list(filter(lambda i: b[i] == M... | output | 1 | 807 | 12 | 1,615 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a... | instruction | 0 | 808 | 12 | 1,616 |
Tags: constructive algorithms
Correct Solution:
```
n = int(input())
b = list(map(int, input().split()))
pos = [i for i in range(n) if b[i] > b[i - 1]]
if not pos:
if b[0] == 0:
a = [1] * n
print('YES')
print(*a)
else:
print('NO')
else:
x = pos[0]
a = [0] * n
a[x] = ... | output | 1 | 808 | 12 | 1,617 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a... | instruction | 0 | 809 | 12 | 1,618 |
Tags: constructive algorithms
Correct Solution:
```
n=int(input())
b=[]
b=[int(el) for el in input().split()]
n=len(b)
i=n-1
while b[i-1]>=b[i] and i>0:
i=i-1
if i==0 and b[0]==b[n-1]:
if b[0]!=0:
print ('NO')
raise SystemExit()
else:
print('YES')
print(" ".join(str(1) for i ... | output | 1 | 809 | 12 | 1,619 |
Provide tags and a correct Python 3 solution for this coding contest problem.
While discussing a proper problem A for a Codeforces Round, Kostya created a cyclic array of positive integers a_1, a_2, …, a_n. Since the talk was long and not promising, Kostya created a new cyclic array b_1, b_2, …, b_{n} so that b_i = (a... | instruction | 0 | 810 | 12 | 1,620 |
Tags: constructive algorithms
Correct Solution:
```
from sys import stdin
n = int(stdin.readline())
b = [int(x) for x in stdin.readline().strip().split()]
start = -1
a = [0]*n
for i in range(n):
if b[i] < b[(i+1)%n]:
start = (i+1)%n
break
if max(b) == 0:
print('YES')
print(' '.join(['123']*n... | output | 1 | 810 | 12 | 1,621 |
End of preview. Expand in Data Studio
- Downloads last month
- 8