message stringlengths 2 43.5k | message_type stringclasses 2
values | message_id int64 0 1 | conversation_id int64 853 107k | cluster float64 24 24 | __index_level_0__ int64 1.71k 214k |
|---|---|---|---|---|---|
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,735 | 24 | 157,470 |
Tags: brute force, dp
Correct Solution:
```
# @author: guoyc
# @date: 2018/7/21
N, a, b = [int(_) for _ in input().split()]
h = [int(_) for _ in input().split()]
t = h[-1] // b + 1
h[-1] -= t * b
h[-2] -= t * a
h[-3] -= t * b
import sys
res = [sys.maxsize, None]
cnt = [0] * N
# print(t)
# print(h)
def search(... | output | 1 | 78,735 | 24 | 157,471 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,736 | 24 | 157,472 |
Tags: brute force, dp
Correct Solution:
```
#!/usr/bin/env python
def main():
n, a, b = map(int, input().split())
health = [0]
health.extend(map(int, input().split()))
target = [0] * len(health)
def need(t, d):
nonlocal health
p = health[t]
return (p // d + 1) if p >= 0 el... | output | 1 | 78,736 | 24 | 157,473 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,737 | 24 | 157,474 |
Tags: brute force, dp
Correct Solution:
```
res = 10000
path = []
n, a, b = map(int, input().split())
def solve(cnt, idx, arc, p):
global res
global path
if idx == n - 1:
if res > cnt:
res = cnt
path = p.copy()
return
if cnt > res:
return
if arc[idx] <... | output | 1 | 78,737 | 24 | 157,475 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,738 | 24 | 157,476 |
Tags: brute force, dp
Correct Solution:
```
__author__ = 'Darren'
def solve():
n, a, b = map(int, input().split())
h = [0]
h.extend(map(int, input().split()))
fires = []
count = h[1] // b + 1 if h[1] >= 0 else 0
fires.extend([2 for i in range(count)])
h[1] -= b * count
h[2] -= a * cou... | output | 1 | 78,738 | 24 | 157,477 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,739 | 24 | 157,478 |
Tags: brute force, dp
Correct Solution:
```
n,a,b=map(int,input().split())
h=list(map(int,input().split()))
t=h[-1]//b+1
h[-1]-=t*b
h[-2]-=t*a
h[-3]-=t*b
import sys
res=[sys.maxsize,None]
c=[0]*n
def search(i,cur):
if(i==n-1):
res[0]=cur
c[n-2]+=t
res[1]=c[:]
return
if(h[i-1]>=... | output | 1 | 78,739 | 24 | 157,479 |
Provide tags and a correct Python 3 solution for this coding contest problem.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp likes to play computer role-playing game «Lizards ... | instruction | 0 | 78,740 | 24 | 157,480 |
Tags: brute force, dp
Correct Solution:
```
import sys
n,a,b=map(int,input().split())
h=list(map(int,input().split()))
t=h[-1] // b+1
h[-1]-=t*b
h[-2]-=t*a
h[-3]-=t*b
res=[sys.maxsize,None]
cnt=[0]*n
def search(idx,cur):
if idx==n-1:
res[0]=cur
cnt[n-2]+=t
res[1]=cnt[:]
return
... | output | 1 | 78,740 | 24 | 157,481 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp lik... | instruction | 0 | 78,744 | 24 | 157,488 |
Yes | output | 1 | 78,744 | 24 | 157,489 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp lik... | instruction | 0 | 78,745 | 24 | 157,490 |
No | output | 1 | 78,745 | 24 | 157,491 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
This is simplified version of the problem used on the original contest. The original problem seems to have too difiicult solution. The constraints for input data have been reduced.
Polycarp lik... | instruction | 0 | 78,747 | 24 | 157,494 |
No | output | 1 | 78,747 | 24 | 157,495 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,183 | 24 | 158,366 |
Tags: binary search, greedy
Correct Solution:
```
n, m = map(int, input().split())
A = list(map(int, input().split()))
A.sort()
A.reverse()
def func(i):
ans = 0
for j in range(0, n):
ans += max(A[j] - j // i, 0)
return ans >= m
l = 1
r = n
while (r - l) > 1:
s = (l + r) >> 1
if func(s) == 1:... | output | 1 | 79,183 | 24 | 158,367 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,184 | 24 | 158,368 |
Tags: binary search, greedy
Correct Solution:
```
import math,sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda:int(input())
li = lambda:list(map(int,input().split()))
def solve(a,mid,s):
c=0
i=0
p=0
while(i<len(a)):
c+=max(0,a[i]-p)
i=i+1
... | output | 1 | 79,184 | 24 | 158,369 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,185 | 24 | 158,370 |
Tags: binary search, greedy
Correct Solution:
```
import sys
input = sys.stdin.readline
def judge(x):
b = a[:]
for i in range(n):
b[i] = max(0, b[i]-i//x)
return sum(b)>=m
def binary_search():
l, r = 1, n
while l<=r:
m = (l+r)//2
if judge(m):
... | output | 1 | 79,185 | 24 | 158,371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,186 | 24 | 158,372 |
Tags: binary search, greedy
Correct Solution:
```
def check_possibility(days, m, coffee):
sum_coffee = 0
for i, cup in enumerate(coffee):
tax = i // days
if sum_coffee >= m or tax >= cup:
break
sum_coffee += cup - tax
return sum_coffee >= m
n, m = map(int, input().split... | output | 1 | 79,186 | 24 | 158,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,187 | 24 | 158,374 |
Tags: binary search, greedy
Correct Solution:
```
import sys,os,io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from bisect import bisect_left , bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
d... | output | 1 | 79,187 | 24 | 158,375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,188 | 24 | 158,376 |
Tags: binary search, greedy
Correct Solution:
```
n, m = map(int, input().split())
A = list(map(int, input().split()))
if sum(A) < m:
print(-1)
exit()
A.sort(reverse=True)
def is_ok(x):
temp = 0
for i in range(n):
temp += max(0, A[i]-i//x)
if temp >= m:
return True
else:
... | output | 1 | 79,188 | 24 | 158,377 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,189 | 24 | 158,378 |
Tags: binary search, greedy
Correct Solution:
```
import sys
import math
input = sys.stdin.readline
for _ in range(1):
n,m = map(int,input().split())
l = list(map(int,input().split()))
l.sort(reverse = True)
if sum(l) < m:
print(-1)
continue
ans = 10**18
low = 1
high = n
... | output | 1 | 79,189 | 24 | 158,379 |
Provide tags and a correct Python 3 solution for this coding contest problem.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in the i-th cup Polycarp has a_i caffeine in it. ... | instruction | 0 | 79,190 | 24 | 158,380 |
Tags: binary search, greedy
Correct Solution:
```
n, m = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(reverse=True)
def check(d):
s=0
for i in range(len(a)):
s+=max(0,a[i]-i//d)
return s>=m
if sum(a)<m:
print(-1)
else:
l, r = 1,n
mid = l+r>>1
while ... | output | 1 | 79,190 | 24 | 158,381 |
Evaluate the correctness of the submitted Python 2 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,191 | 24 | 158,382 |
Yes | output | 1 | 79,191 | 24 | 158,383 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,192 | 24 | 158,384 |
Yes | output | 1 | 79,192 | 24 | 158,385 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,193 | 24 | 158,386 |
Yes | output | 1 | 79,193 | 24 | 158,387 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,194 | 24 | 158,388 |
Yes | output | 1 | 79,194 | 24 | 158,389 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,195 | 24 | 158,390 |
Yes | output | 1 | 79,195 | 24 | 158,391 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,196 | 24 | 158,392 |
No | output | 1 | 79,196 | 24 | 158,393 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,197 | 24 | 158,394 |
No | output | 1 | 79,197 | 24 | 158,395 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,198 | 24 | 158,396 |
No | output | 1 | 79,198 | 24 | 158,397 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
The only difference between easy and hard versions is the constraints.
Polycarp has to write a coursework. The coursework consists of m pages.
Polycarp also has n cups of coffee. The coffee in... | instruction | 0 | 79,199 | 24 | 158,398 |
No | output | 1 | 79,199 | 24 | 158,399 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,604 | 24 | 159,208 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
ls = [[] for _ in range(10**6//4)]
maxd = 0
s=input().split(",")
i = 0
stack = [1000000]
for i in range(0, len(s), 2):
w,c = s[i],int(s[i+1])
ls[len(stack)-1].append(w)
stack[-1]-=1
stack.append(c)
while stack[-1]==0: stack.po... | output | 1 | 79,604 | 24 | 159,209 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,605 | 24 | 159,210 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
t = input().split(',')
w = t[::2]
c = list(map(lambda x : int(x), t[1::2]))
max_d = 0
cur_d = 0
cnt = [10**6]
ans = [[] for i in range(10**6)]
i = 0
while i < len(w):
ans[cur_d].append(w[i])
cnt[cur_d] -= 1
if c[i] > 0:
cn... | output | 1 | 79,605 | 24 | 159,211 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,606 | 24 | 159,212 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
import sys
from typing import List
slist = input().split(',') # type: List[str]
stack = [1<<30] # type: List[int]
res = [[]]
for s in slist:
if s.isnumeric():
stack.append(int(s))
if len(stack) > len(res):
... | output | 1 | 79,606 | 24 | 159,213 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,607 | 24 | 159,214 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
a = input().split(',')
o = 0
for i in range(1, len(a), 2):
a[i] = int(a[i])
b = [[] for i in range(300000)]
c = []
for i in range(0, len(a), 2):
b[len(c)] += [a[i]]
if a[i + 1] == 0:
if len(c) != 0:
... | output | 1 | 79,607 | 24 | 159,215 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,608 | 24 | 159,216 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
line = input()
line = line.split(',')
A = 'abcdefghijklmnopqrstuvwxyz'
depth = 1
comments = [[]]
cur_cnt, cur_depth = [0], 1
for token in line:
if token[0] in A or token[0] in A.upper():
comments[cur_depth - 1].append(... | output | 1 | 79,608 | 24 | 159,217 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,609 | 24 | 159,218 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
t = input().split(',')
k, m = 0, len(t)
p, d = [m] * m, [[] for i in range(m)]
for s, n in zip(t[::2], t[1::2]):
while not p[k]: k -= 1
p[k] -= 1
d[k].append(s)
k += 1
p[k] = int(n)
while d[k]: k += 1
print(k)
f... | output | 1 | 79,609 | 24 | 159,219 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,610 | 24 | 159,220 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
tokens = input().split(',')
depths = []
stk = [len(tokens)]
for i in range(len(tokens)//2):
tok = tokens[2*i]
children = int(tokens[2*i+1])
y = stk.pop()
y -= 1
stk.append(y)
while len(depths) <= len(stk... | output | 1 | 79,610 | 24 | 159,221 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string consisting of uppercase and lowercase letters of ... | instruction | 0 | 79,611 | 24 | 159,222 |
Tags: dfs and similar, expression parsing, implementation, strings
Correct Solution:
```
t = input().split(',')
m = len(t)
p, d, k = [m] * m, [[] for i in range(m)], 0
for i in range(0, m, 2):
s, n = t[i], int(t[i + 1])
while p[k] == 0: k -= 1
p[k] -= 1
d[k].append(s)
k += 1
p[k] = n
while d[k]:... | output | 1 | 79,611 | 24 | 159,223 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,612 | 24 | 159,224 |
Yes | output | 1 | 79,612 | 24 | 159,225 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,613 | 24 | 159,226 |
Yes | output | 1 | 79,613 | 24 | 159,227 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,614 | 24 | 159,228 |
Yes | output | 1 | 79,614 | 24 | 159,229 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,615 | 24 | 159,230 |
Yes | output | 1 | 79,615 | 24 | 159,231 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,616 | 24 | 159,232 |
No | output | 1 | 79,616 | 24 | 159,233 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,617 | 24 | 159,234 |
No | output | 1 | 79,617 | 24 | 159,235 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,618 | 24 | 159,236 |
No | output | 1 | 79,618 | 24 | 159,237 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A rare article in the Internet is posted without a possibility to comment it. On a Polycarp's website each article has comments feed.
Each comment on Polycarp's website is a non-empty string co... | instruction | 0 | 79,619 | 24 | 159,238 |
No | output | 1 | 79,619 | 24 | 159,239 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,181 | 24 | 160,362 |
Tags: brute force, dp, greedy
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input())
arr = list(map(int,input().split()))
mn = min(arr)
mx = max(arr)
mni = arr.index(mn)
mxi = arr.index(mx)
if mxi>mni:
print(min(mxi+1,n-mni,mni+1+n-mxi))
else:
print(min(mn... | output | 1 | 80,181 | 24 | 160,363 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,182 | 24 | 160,364 |
Tags: brute force, dp, greedy
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input())
lst=list(map(int,input().split(' ')))
mx=max(lst)
mn=min(lst)
mni=0
mnx=0
for i in range(n):
if lst[i]==mn:
mni=i
if lst[i]==mx:
mnx=i
if mni<mnx:
... | output | 1 | 80,182 | 24 | 160,365 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,183 | 24 | 160,366 |
Tags: brute force, dp, greedy
Correct Solution:
```
import math
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
a=max(l)
b=min(l)
c=l.index(a)+1
d=l.index(b)+1
e=n-c+1
f=n-d+1
l=min(c+f,d+e,max(c,d),max(e,f))
print(l)
``` | output | 1 | 80,183 | 24 | 160,367 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,184 | 24 | 160,368 |
Tags: brute force, dp, greedy
Correct Solution:
```
for t in range(int(input())):
n = int(input())
l = [int(x) for x in input().split()]
mni=0
mxi=0
for i in range(n):
if(l[i]==1):
mni=i
if(l[i]==n):
mxi=i
a=min(mni,mxi)
b=max(mni,mxi)
p1=b+1
p... | output | 1 | 80,184 | 24 | 160,369 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,185 | 24 | 160,370 |
Tags: brute force, dp, greedy
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
l=list(map(int,input().split()))
mx,mn=0,0
for i in range(1,n):
if(l[mx]<l[i]):
mx=i
elif (l[mn]>l[i]):
mn=i
if(mx<mn):
mx,mn=mn,mx
print(n-max(mn,mx-mn-1,n-mx-1))
``` | output | 1 | 80,185 | 24 | 160,371 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,186 | 24 | 160,372 |
Tags: brute force, dp, greedy
Correct Solution:
```
from math import *
sInt = lambda: int(input())
mInt = lambda: map(int, input().split())
lInt = lambda: list(map(int, input().split()))
py = lambda: print("YES")
pn = lambda: print("NO")
t = sInt()
for _ in range(t):
n = sInt()
a = lInt()
b = sorted(a)
... | output | 1 | 80,186 | 24 | 160,373 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,187 | 24 | 160,374 |
Tags: brute force, dp, greedy
Correct Solution:
```
for i in range(int(input())):
n = int(input())
ar = list(map(int,input().split()))
l_pos = ar.index(1)+1
r_pos = ar.index(n)+1
if l_pos>r_pos:
temp = l_pos
l_pos = r_pos
r_pos = temp
ans1 = l_pos-1 ... | output | 1 | 80,187 | 24 | 160,375 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Polycarp is playing a new computer game. This game has n stones in a row. The stone on the position i has integer power a_i. The powers of all stones are distinct.
Each turn Polycarp can destroy either stone on the first position or stone o... | instruction | 0 | 80,188 | 24 | 160,376 |
Tags: brute force, dp, greedy
Correct Solution:
```
def solve(arr,n,ans):
i1,i2 = arr.index(min(arr)),arr.index(max(arr))
i1,i2 = min(i1,i2),max(i1,i2)
min_val = min(i1+1+n-i2,i2+1,n-i1)
ans.append(str(min_val))
def main():
t = int(input())
ans = []
for i in range(t):
n = int(input(... | output | 1 | 80,188 | 24 | 160,377 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.