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.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutations: [3, 4, 1, 2], [1], [1, 2]. The following s... | instruction | 0 | 64,933 | 12 | 129,866 |
Tags: constructive algorithms
Correct Solution:
```
t = int(input())
for _ in range(t):
n = int(input())
a = list(map(int, input().split()))
l = set(a)
s = sorted(list(i for i in range(1, 1+n) if i not in l))[::-1]
ar = a.copy()
ok = True
for i in range(1, n):
if a[i] == a... | output | 1 | 64,933 | 12 | 129,867 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutations: [3, 4, 1, 2], [1], [1, 2]. The following s... | instruction | 0 | 64,934 | 12 | 129,868 |
Tags: constructive algorithms
Correct Solution:
```
t=int(input())
for i in range(t):
n=int(input())
q=[int(x) for x in input().strip().split()]
boo=[True]*(n+1)
p=[0]*n
p[0]=q[0]
boo[q[0]-1]=False
for j in range(1,n):
if q[j]!=q[j-1]:
p[j]=q[j]
boo[q[j]-1]=Fa... | output | 1 | 64,934 | 12 | 129,869 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,935 | 12 | 129,870 |
Yes | output | 1 | 64,935 | 12 | 129,871 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,936 | 12 | 129,872 |
Yes | output | 1 | 64,936 | 12 | 129,873 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,937 | 12 | 129,874 |
Yes | output | 1 | 64,937 | 12 | 129,875 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,938 | 12 | 129,876 |
Yes | output | 1 | 64,938 | 12 | 129,877 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,939 | 12 | 129,878 |
No | output | 1 | 64,939 | 12 | 129,879 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,940 | 12 | 129,880 |
No | output | 1 | 64,940 | 12 | 129,881 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,941 | 12 | 129,882 |
No | output | 1 | 64,941 | 12 | 129,883 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Permutation p is a sequence of integers p=[p_1, p_2, ..., p_n], consisting of n distinct (unique) positive integers between 1 and n, inclusive. For example, the following sequences are permutati... | instruction | 0 | 64,942 | 12 | 129,884 |
No | output | 1 | 64,942 | 12 | 129,885 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,007 | 12 | 130,014 |
Tags: binary search, data structures
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')
def read_int():
res = b''
while True:
d = sys.stdin.buffer.read(1)
if d == b'-' o... | output | 1 | 65,007 | 12 | 130,015 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,008 | 12 | 130,016 |
Tags: binary search, data structures
Correct Solution:
```
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict... | output | 1 | 65,008 | 12 | 130,017 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,009 | 12 | 130,018 |
Tags: binary search, data structures
Correct Solution:
```
from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
from __builtin__ import xrange as range
from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict... | output | 1 | 65,009 | 12 | 130,019 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,010 | 12 | 130,020 |
Tags: binary search, data structures
Correct Solution:
```
# ll = lambda: list(map(int, input().split()))
# s = lambda: input()
# v = lambda: map(int, input().split())
# ii = lambda: int(input())
import math
import os
import sys
input = sys.stdin.readline
ii = 0
_inp = b''
def getchar():
global ii, _inp
if ii >... | output | 1 | 65,010 | 12 | 130,021 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,011 | 12 | 130,022 |
Tags: binary search, data structures
Correct Solution:
```
import os
import sys
input = sys.stdin.readline
ii = 0
_inp = b''
def getchar():
global ii, _inp
if ii >= len(_inp):
_inp = os.read(0, 4000)
ii = 0
if not _inp:
return b' '[0]
ii += 1
return _inp[ii - 1]
def inp... | output | 1 | 65,011 | 12 | 130,023 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,012 | 12 | 130,024 |
Tags: binary search, data structures
Correct Solution:
```
import sys, os, gc
ii = 0
_inp = b''
def getchar():
global ii, _inp
if ii >= len(_inp):
_inp = os.read(0, 25000)
gc.collect()
ii = 0
if not _inp:
return b' '[0]
ii += 1
return _inp[ii - 1]
def input():
... | output | 1 | 65,012 | 12 | 130,025 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,013 | 12 | 130,026 |
Tags: binary search, data structures
Correct Solution:
```
'''
#------------------------------------------------------------------------
import os
import sys
#------------------------------------------------------------------------
def RL(): return map(int, sys.stdin.readline().rstrip().split())
def RLL(): return list... | output | 1 | 65,013 | 12 | 130,027 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th order statistics in the multiset and remove it.
... | instruction | 0 | 65,014 | 12 | 130,028 |
Tags: binary search, data structures
Correct Solution:
```
"""
#If FastIO not needed, used this and don't forget to strip
#import sys, math
#input = sys.stdin.readline
"""
import sys, os, gc
ii = 0
_inp = b''
def getchar():
global ii, _inp
if ii >= len(_inp):
_inp = os.read(0, 50000)
gc.colle... | output | 1 | 65,014 | 12 | 130,029 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,015 | 12 | 130,030 |
Yes | output | 1 | 65,015 | 12 | 130,031 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,016 | 12 | 130,032 |
Yes | output | 1 | 65,016 | 12 | 130,033 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,017 | 12 | 130,034 |
Yes | output | 1 | 65,017 | 12 | 130,035 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,018 | 12 | 130,036 |
Yes | output | 1 | 65,018 | 12 | 130,037 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,019 | 12 | 130,038 |
No | output | 1 | 65,019 | 12 | 130,039 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,020 | 12 | 130,040 |
No | output | 1 | 65,020 | 12 | 130,041 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,021 | 12 | 130,042 |
No | output | 1 | 65,021 | 12 | 130,043 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Note that the memory limit is unusual.
You are given a multiset consisting of n integers. You have to process queries of two types:
* add integer k into the multiset;
* find the k-th orde... | instruction | 0 | 65,022 | 12 | 130,044 |
No | output | 1 | 65,022 | 12 | 130,045 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,092 | 12 | 130,184 |
Tags: constructive algorithms, implementation
Correct Solution:
```
t = int(input())
for _ in range(t):
n,k = map(int,input().split())
l=[]
m=[]
if (k*2+1)>n:
print(-1)
else:
l.append(1)
for i in range(2,n+1):
if i not in m:
if k:
... | output | 1 | 65,092 | 12 | 130,185 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,093 | 12 | 130,186 |
Tags: constructive algorithms, implementation
Correct Solution:
```
for s in[*open(0)][1:]:
n,k=map(int,s.split());a=[*range(1,n+1)];i=1
while i<min(n-1,2*k):a[i],a[i+1]=a[i+1],a[i];i+=2
print(*(a,[-1])[i<2*k])
``` | output | 1 | 65,093 | 12 | 130,187 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,094 | 12 | 130,188 |
Tags: constructive algorithms, implementation
Correct Solution:
```
# import sys
# sys.stdin=open('input.txt','r')
# sys.stdout=open('output.txt','w')
def arrIn():
return list(map(int,input().split()))
def mapIn():
return map(int,input().split())
def check_palindrome(s):
n=len(s)
for i in range(n):
... | output | 1 | 65,094 | 12 | 130,189 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,095 | 12 | 130,190 |
Tags: constructive algorithms, implementation
Correct Solution:
```
# right answer
import math
t = int(input())
for asdfasfd in range(0, t):
n, a = map(int, input().split())
perm = [x for x in range(1, n + 1)]
if a > math.ceil(n/2) - 1:
print("-1")
else:
# there is the permutation
... | output | 1 | 65,095 | 12 | 130,191 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,096 | 12 | 130,192 |
Tags: constructive algorithms, implementation
Correct Solution:
```
test_count = int(input())
for _ in range(test_count):
n,k = [int(x) for x in input().split()]
max_k = (n-1)//2
if k>max_k:
print ('-1')
continue
arr = list(range(1,n+1))
for i in range(k):
arr[2*i+1]= 2*i+3
... | output | 1 | 65,096 | 12 | 130,193 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,097 | 12 | 130,194 |
Tags: constructive algorithms, implementation
Correct Solution:
```
for s in[*open(0)][1:]:
n,k=map(int,s.split());a=[*range(1,n+1)];i=1
while i<2*k:a[i:i+2]=a[i+1:i-1:-1];i+=2
print(*(a,[-1])[i>n])
``` | output | 1 | 65,097 | 12 | 130,195 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,098 | 12 | 130,196 |
Tags: constructive algorithms, implementation
Correct Solution:
```
def solve(n,k):
if k==0:
print(*range(1,n+1))
elif k==1 and n==2:
print(-1)
elif k==n:
print(-1)
elif k>=(n+1)//2:
print(-1)
else:
ans = [0 for i in range(n)]
i = 1
c=0
... | output | 1 | 65,098 | 12 | 130,197 |
Provide tags and a correct Python 3 solution for this coding contest problem.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exactly k peaks. An index i of an array a of size ... | instruction | 0 | 65,099 | 12 | 130,198 |
Tags: constructive algorithms, implementation
Correct Solution:
```
'''
Author : Shubhanshu Jain;
'''
import math
import random;
from collections import *
mod =1000000007
r1 = lambda : int(input());
rm = lambda : map(int,input().split());
rms = lambda : map(str,input().split());
rls = lambda : list(rm())
def s... | output | 1 | 65,099 | 12 | 130,199 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,100 | 12 | 130,200 |
Yes | output | 1 | 65,100 | 12 | 130,201 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,101 | 12 | 130,202 |
Yes | output | 1 | 65,101 | 12 | 130,203 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,102 | 12 | 130,204 |
Yes | output | 1 | 65,102 | 12 | 130,205 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,103 | 12 | 130,206 |
Yes | output | 1 | 65,103 | 12 | 130,207 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,104 | 12 | 130,208 |
No | output | 1 | 65,104 | 12 | 130,209 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,105 | 12 | 130,210 |
No | output | 1 | 65,105 | 12 | 130,211 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,106 | 12 | 130,212 |
No | output | 1 | 65,106 | 12 | 130,213 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
A sequence of n integers is called a permutation if it contains all integers from 1 to n exactly once.
Given two integers n and k, construct a permutation a of numbers from 1 to n which has exa... | instruction | 0 | 65,107 | 12 | 130,214 |
No | output | 1 | 65,107 | 12 | 130,215 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its eleme... | instruction | 0 | 65,153 | 12 | 130,306 |
No | output | 1 | 65,153 | 12 | 130,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its eleme... | instruction | 0 | 65,154 | 12 | 130,308 |
No | output | 1 | 65,154 | 12 | 130,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its eleme... | instruction | 0 | 65,155 | 12 | 130,310 |
No | output | 1 | 65,155 | 12 | 130,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Vasya's got a birthday coming up and his mom decided to give him an array of positive integers a of length n.
Vasya thinks that an array's beauty is the greatest common divisor of all its eleme... | instruction | 0 | 65,156 | 12 | 130,312 |
No | output | 1 | 65,156 | 12 | 130,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 β€ l β€ r β€ n. Indices in array are... | instruction | 0 | 65,357 | 12 | 130,714 |
Tags: brute force, data structures, dp
Correct Solution:
```
class MaxSegTree:
def __init__(self, zero, data=None, size=None):
if data is None and size is None:
raise Exception('data and size both cannot be None simultaneously')
if size is None:
size = len(data)
depth = (size-1).bit_length()
... | output | 1 | 65,357 | 12 | 130,715 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 β€ l β€ r β€ n. Indices in array are... | instruction | 0 | 65,358 | 12 | 130,716 |
Tags: brute force, data structures, dp
Correct Solution:
```
n=int(input())
a=[5]+list(map(int,input().split()))
dp=[[[i,0] for i in range(n+1)] for j in range(4)]
end=n
indx_a,indx_b,indx_c=0,0,0
for i in range(1,n+1):
dp[0][i][1]=dp[0][i-1][1]+a[i]
dp[1][i][1]=max(dp[0][i-1][1],dp[1][i-1][1])-a[i]
dp[2][i... | output | 1 | 65,358 | 12 | 130,717 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array of n integer numbers. Let sum(l, r) be the sum of all numbers on positions from l to r non-inclusive (l-th element is counted, r-th element is not counted). For indices l and r holds 0 β€ l β€ r β€ n. Indices in array are... | instruction | 0 | 65,359 | 12 | 130,718 |
Tags: brute force, data structures, dp
Correct Solution:
```
n = int(input())
nums = [int(x) for x in input().split()]
best = [None for x in range(len(nums))]
way = [None for x in range(len(nums))]
def find_best_way():
global best, n, nums, way
for j in range(n - 1, -1, -1):
best[j] = dict()
... | output | 1 | 65,359 | 12 | 130,719 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Let's call beauty of an array b_1, b_2, β¦, b_n (n > 1) β min_{1 β€ i < j β€ n} |b_i - b_j|.
You're given an array a_1, a_2, β¦ a_n and a number k. Calculate the sum of beauty over all subsequences of the array of length exactly k. As this numb... | instruction | 0 | 65,681 | 12 | 131,362 |
Tags: dp
Correct Solution:
```
from collections import defaultdict
import sys
input = sys.stdin.readline
'''
for CASES in range(int(input())):
n, m = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))
S = input().strip()
sys.stdout.write(" ".join(map(str,ans))+"\n")
'''
inf = 100000000000000... | output | 1 | 65,681 | 12 | 131,363 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.