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.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,645 | 12 | 41,290 |
Tags: brute force, sortings
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
res = a[0]
for l in range(n):
for r in range(l, n):
inside = sorted(a[l:r+1])
outside = sorted(a[:l] + a[r+1:], reverse=True)
new_res = sum(inside)
for i in range(min(k, len(inside), len(o... | output | 1 | 20,645 | 12 | 41,291 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,646 | 12 | 41,292 |
Tags: brute force, sortings
Correct Solution:
```
n, k = map(int, input().split())
a = list(map(int, input().split()))
def solve(i, j):
cur_res = sum(a[i:j+1])
a1 = sorted(a[i:j+1])
a2 = sorted(a[:i] + a[j+1:], reverse=True)
for t in range(min(k, len(a1), len(a2))):
m = min(a1)
if a2[t]... | output | 1 | 20,646 | 12 | 41,293 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,647 | 12 | 41,294 |
Tags: brute force, sortings
Correct Solution:
```
n, k = [int(c) for c in input().split()]
a = [int(c) for c in input().split()]
best = -1000001
seq = []
other = []
for l in range(n):
for r in range(l + 1, n + 1):
seq = sorted(a[l:r])
other = a[:l] + a[r:]
other.sort()
other.reve... | output | 1 | 20,647 | 12 | 41,295 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,648 | 12 | 41,296 |
Tags: brute force, sortings
Correct Solution:
```
R = lambda:map(int, input().split())
n, k = R()
a = list(R())
def f(l, r):
x = sorted(a[:l] + a[r + 1:], reverse=True)
y = sorted(a[l:r + 1])
return sum(y + [max(0, x[i] - y[i]) for i in range(min(k, len(x), len(y)))])
print(max(f(l, r) for l in range(n) for r in ... | output | 1 | 20,648 | 12 | 41,297 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,649 | 12 | 41,298 |
Tags: brute force, sortings
Correct Solution:
```
n,m=map(int,input().split())
lis=list(map(int,input().split()))
k=-100000000
for l in range(n):
for r in range(l+1,n+1):
k=max(k,sum(sorted(lis[l:r] + sorted(lis[:l]+lis[r:])[-m:])[l-r:]))
print(k)
``` | output | 1 | 20,649 | 12 | 41,299 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,650 | 12 | 41,300 |
Tags: brute force, sortings
Correct Solution:
```
__author__ = 'Lipen'
def main():
n, k = map(int, input().split())
a = list(map(int, input().split()))
s = a[0]
for l in range(n):
for r in range(l,n):
out = sorted(a[:l] + a[r+1:], reverse=True)
inside = sorted(a[l:r+1])
temp = sum(a[l:r+1])
for i in... | output | 1 | 20,650 | 12 | 41,301 |
Provide tags and a correct Python 3 solution for this coding contest problem.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes i, j (i β j);
* perform assignments tmp = a... | instruction | 0 | 20,651 | 12 | 41,302 |
Tags: brute force, sortings
Correct Solution:
```
read_line = lambda: [int(i) for i in input().split()]
n, k = read_line()
x = read_line()
print(max(sum(sorted(x[l:r] + sorted(x[:l] + x[r:])[-k:])[l-r:]) for l in range(n) for r in range(l + 1, n + 1)))
# Made By Mostafa_Khaled
``` | output | 1 | 20,651 | 12 | 41,303 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes... | instruction | 0 | 20,652 | 12 | 41,304 |
Yes | output | 1 | 20,652 | 12 | 41,305 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes... | instruction | 0 | 20,653 | 12 | 41,306 |
No | output | 1 | 20,653 | 12 | 41,307 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes... | instruction | 0 | 20,654 | 12 | 41,308 |
No | output | 1 | 20,654 | 12 | 41,309 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes... | instruction | 0 | 20,655 | 12 | 41,310 |
No | output | 1 | 20,655 | 12 | 41,311 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
As usual, Sereja has array a, its elements are integers: a[1], a[2], ..., a[n]. Let's introduce notation:
<image>
A swap operation is the following sequence of actions:
* choose two indexes... | instruction | 0 | 20,656 | 12 | 41,312 |
No | output | 1 | 20,656 | 12 | 41,313 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,261 | 12 | 42,522 |
Tags: sortings
Correct Solution:
```
import sys,math,string
input=sys.stdin.readline
from collections import deque
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
n=int(input())
a=L()
od=0
ev=0
for i in range(n):
if(a[i]%2==0):
ev+=1
else:
... | output | 1 | 21,261 | 12 | 42,523 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,262 | 12 | 42,524 |
Tags: sortings
Correct Solution:
```
n = int(input())
l = list(map(int,input().split()))
od = 0
for el in l:
od += (el&1)
if od > 0 and (n-od) != 0:
l.sort()
print(*l)
``` | output | 1 | 21,262 | 12 | 42,525 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,263 | 12 | 42,526 |
Tags: sortings
Correct Solution:
```
size = int(input())
a = list(map(int, input().split()))
f1 = f2 = False
for i in a:
if i % 2 != 0:
f1 = True
else:
f2 = True
if f1 and f2:
print(*sorted(a))
else:
print(*a)
``` | output | 1 | 21,263 | 12 | 42,527 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,264 | 12 | 42,528 |
Tags: sortings
Correct Solution:
```
n = int(input())
a1 = list(map(int, input().split()))
a, b = 0, 0
for i in a1:
if i % 2 == 0:
a += 1
else:
b+=1
if a != 0 and b != 0:
a1.sort()
print(*a1)
else:
print(*a1)
``` | output | 1 | 21,264 | 12 | 42,529 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,265 | 12 | 42,530 |
Tags: sortings
Correct Solution:
```
if __name__ == '__main__':
n = int(input())
aa = list(map(int, input().split()))
odd, even = False, False
for a in aa:
if a%2==0:
odd = True
else:
even = True
if odd and even:
break
if odd and even:
... | output | 1 | 21,265 | 12 | 42,531 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,266 | 12 | 42,532 |
Tags: sortings
Correct Solution:
```
from math import *
n = int(input())
l = list(map(int,input().split()))
a = [0,0]
for i in l:
a[i%2] += 1
if(a[0] == 0 or a[1] == 0):
for i in l:
print(i,end = " ")
print()
else:
l.sort()
for i in l:
print(i,end = " ")
print()
``` | output | 1 | 21,266 | 12 | 42,533 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,267 | 12 | 42,534 |
Tags: sortings
Correct Solution:
```
n = int(input())
l = [int(x) for x in input().split(" ")]
odd,even = 0,0
for i in l:
if i%2: odd += 1
else: even += 1
if odd and even: l.sort()
print(*l)
``` | output | 1 | 21,267 | 12 | 42,535 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i and a_j.
What is lexicographically the sma... | instruction | 0 | 21,268 | 12 | 42,536 |
Tags: sortings
Correct Solution:
```
n = int(input())
ls = list(map(int,input().split()))
b = [0,0]
for i in range(n):
b[ls[i]%2]=1
if b[0] and b[1]:
ls.sort()
for j in range(n):
print (ls[j],end = ' ')
``` | output | 1 | 21,268 | 12 | 42,537 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,269 | 12 | 42,538 |
Yes | output | 1 | 21,269 | 12 | 42,539 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,270 | 12 | 42,540 |
Yes | output | 1 | 21,270 | 12 | 42,541 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,271 | 12 | 42,542 |
Yes | output | 1 | 21,271 | 12 | 42,543 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,272 | 12 | 42,544 |
Yes | output | 1 | 21,272 | 12 | 42,545 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,273 | 12 | 42,546 |
No | output | 1 | 21,273 | 12 | 42,547 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,274 | 12 | 42,548 |
No | output | 1 | 21,274 | 12 | 42,549 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,275 | 12 | 42,550 |
No | output | 1 | 21,275 | 12 | 42,551 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
You're given an array a of length n. You can perform the following operation on it as many times as you want:
* Pick two integers i and j (1 β€ i,j β€ n) such that a_i+a_j is odd, then swap a_i... | instruction | 0 | 21,276 | 12 | 42,552 |
No | output | 1 | 21,276 | 12 | 42,553 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,347 | 12 | 42,694 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n = int(input())
array = list(map(int, input().split(" ")))
if (max(array) == 1):
del array[0]
array.append(2)
else:
array.remove(max(array))
array.insert(0, 1)
array.sort()
for i in range (n):
array[i] = str(array[i])
print(" ".join(array))
``` | output | 1 | 21,347 | 12 | 42,695 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,348 | 12 | 42,696 |
Tags: greedy, implementation, sortings
Correct Solution:
```
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
# from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
fro... | output | 1 | 21,348 | 12 | 42,697 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,349 | 12 | 42,698 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n=int(input())
l=[int(i) for i in input().split()]
ind=l.index(max(l))
if l[ind]==1:
l[ind]=2
else:
l[ind]=1
l.sort()
print(*l)
``` | output | 1 | 21,349 | 12 | 42,699 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,350 | 12 | 42,700 |
Tags: greedy, implementation, sortings
Correct Solution:
```
import sys
import math
n=int(input())
lista=[int(x) for x in input().strip().split()]
pap=lista[:]
pap.sort()
if(pap[-1]==1):
pap[-1]=2
else:
pap=[1]+pap[:-1]
for i in range(n):
print(pap[i], end=" ")
``` | output | 1 | 21,350 | 12 | 42,701 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,351 | 12 | 42,702 |
Tags: greedy, implementation, sortings
Correct Solution:
```
a=int(input())
z=list(map(int,input().split()))
z.sort()
if(z.count(1)==len(z)):
z[-1]=2
print(*z)
exit()
ans=[0 for i in range(len(z))]
ans[0]=1
for i in range(1,len(z)):
ans[i]=z[i-1]
print(*ans)
#1 1 1 1 1
``` | output | 1 | 21,351 | 12 | 42,703 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,352 | 12 | 42,704 |
Tags: greedy, implementation, sortings
Correct Solution:
```
import sys
from math import log2,floor,ceil,sqrt,gcd
import bisect
# from collections import deque
# sys.setrecursionlimit(10**5)
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
def input(): return sys... | output | 1 | 21,352 | 12 | 42,705 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,353 | 12 | 42,706 |
Tags: greedy, implementation, sortings
Correct Solution:
```
input()
a=list(map(int,input().split()))
t=max(a)
a[a.index(t)]=[1,2][not t-1]
print(' '.join(map(str,sorted(a))))
``` | output | 1 | 21,353 | 12 | 42,707 |
Provide tags and a correct Python 3 solution for this coding contest problem.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Petya didn't like it at once. He decided to choose ... | instruction | 0 | 21,354 | 12 | 42,708 |
Tags: greedy, implementation, sortings
Correct Solution:
```
n = int(input())
num = list(map(int, input().split()))
mx = max(num)
for i in range(n):
if num[i] == mx:
if mx != 1: num[i] = 1
else: num[i] = 2
break
num.sort()
for i in range(n):
print(num[i], end=" ")
``` | output | 1 | 21,354 | 12 | 42,709 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,355 | 12 | 42,710 |
Yes | output | 1 | 21,355 | 12 | 42,711 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,356 | 12 | 42,712 |
Yes | output | 1 | 21,356 | 12 | 42,713 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,357 | 12 | 42,714 |
Yes | output | 1 | 21,357 | 12 | 42,715 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,358 | 12 | 42,716 |
Yes | output | 1 | 21,358 | 12 | 42,717 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,359 | 12 | 42,718 |
No | output | 1 | 21,359 | 12 | 42,719 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,360 | 12 | 42,720 |
No | output | 1 | 21,360 | 12 | 42,721 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,361 | 12 | 42,722 |
No | output | 1 | 21,361 | 12 | 42,723 |
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response.
Little Petya very much likes arrays consisting of n integers, where each of them is in the range from 1 to 109, inclusive. Recently he has received one such array as a gift from his mother. Pety... | instruction | 0 | 21,362 | 12 | 42,724 |
No | output | 1 | 21,362 | 12 | 42,725 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,405 | 12 | 42,810 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
import io
import os
from collections import Counter, defaultdict, deque
def solve(N, A):
# Decreasing can only be inverted by having left moves in between
# Increasing can only be inverted by having right moves in between
# WLOG, want to ma... | output | 1 | 21,405 | 12 | 42,811 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,406 | 12 | 42,812 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
def solve():
n = int(input())
a = [0] + list(map(int,input().split()))
v = -1
for i in range(1,n+1):
if i == 1:
v = 0
else:
v = max(a[i] - a[i-1] + v,v)
if a[i]< v:
print("NO")
... | output | 1 | 21,406 | 12 | 42,813 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,407 | 12 | 42,814 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
for _ in range(int(input())):
n=int(input())
a=list(map(int,input().split(" ")))
x=0
while x<n-1 and a[x]>=a[x+1]:
x+=1
if x==n-1:
print("YES")
continue
else:
onhold=a[x]
#print(onhold)
... | output | 1 | 21,407 | 12 | 42,815 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,408 | 12 | 42,816 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
import sys
from math import gcd,sqrt,ceil,log2
from collections import defaultdict,Counter,deque
from bisect import bisect_left,bisect_right
import math
sys.setrecursionlimit(2*10**5+10)
import heapq
from itertools import permutations
# input=sys.stdin.re... | output | 1 | 21,408 | 12 | 42,817 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,409 | 12 | 42,818 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
import sys
import os
from io import BytesIO, IOBase
#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
self.writable = "x" in file.mo... | output | 1 | 21,409 | 12 | 42,819 |
Provide tags and a correct Python 3 solution for this coding contest problem.
You are given an array a of n positive integers.
You can use the following operation as many times as you like: select any integer 1 β€ k β€ n and do one of two things:
* decrement by one k of the first elements of the array.
* decreme... | instruction | 0 | 21,410 | 12 | 42,820 |
Tags: constructive algorithms, dp, greedy
Correct Solution:
```
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192
class FastIO(IOBase):
newlines = 0
def __init__(self, file):
self._fd = file.fileno()
self.buffer = BytesIO()
... | output | 1 | 21,410 | 12 | 42,821 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.