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. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,790
12
185,580
Tags: greedy, two pointers Correct Solution: ``` t=int(input()) while t>0 : n=int(input()) l=list(map(int,input().split())) ans=[0,abs(l[1]-l[0])] a=[l[0]] for i in range(2,n) : if ans[i-1]+abs(l[i]-l[i-1]) > ans[i-2]+abs(l[i]-l[i-2]) : ans.append(ans[i-1]+abs(l[i]-l[i-1])) ...
output
1
92,790
12
185,581
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,791
12
185,582
Tags: greedy, two pointers Correct Solution: ``` import sys input = sys.stdin.readline for T in range(int(input())) : n = int(input()) arr = list(map(int ,input().split())) inc = False dec = False res =[arr[0]] for i in range(1,n): if arr[i] < arr[i-1] : if dec : ...
output
1
92,791
12
185,583
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,792
12
185,584
Tags: greedy, two pointers Correct Solution: ``` for _ in range(int(input())): n=int(input()) ar=list(map(int,input().split())) ans=[ar[0]] for i in range(1,n-1): if ar[i]>ar[i-1] and ar[i]>ar[i+1]: ans.append(ar[i]) elif ar[i]<ar[i-1] and ar[i]<ar[i+1]: ans.appen...
output
1
92,792
12
185,585
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,793
12
185,586
Tags: greedy, two pointers Correct Solution: ``` for _ in range(int(input())): n = int(input()) l = list(map(int,input().split())) k = [] # new list after removing c = '' if l[0] < l[1]: c = 'i' # increasing else: c = 'd' # decreasing # x = 1 # start of sequence # count...
output
1
92,793
12
185,587
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,794
12
185,588
Tags: greedy, two pointers Correct Solution: ``` import sys max_int = 1000000001 # 10^9+1 min_int = -max_int t = int(input()) for _t in range(t): n = int(sys.stdin.readline()) p = list(map(int, sys.stdin.readline().split())) d = prev_d = 0 out = [p[0]] for i in range(1, n): if p[i] == p[i...
output
1
92,794
12
185,589
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,795
12
185,590
Tags: greedy, two pointers Correct Solution: ``` import re import sys from bisect import bisect, bisect_left, insort, insort_left from collections import Counter, defaultdict, deque from copy import deepcopy from decimal import Decimal from itertools import ( accumulate, combinations, combinations_with_replacement,...
output
1
92,795
12
185,591
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,796
12
185,592
Tags: greedy, two pointers Correct Solution: ``` import sys from sys import stdin input = sys.stdin.readline for _ in range(int(input())): n=int(input()) arr=[int(j) for j in input().split()] res=[] res.append(arr[0]) count=0 for i in range(1,n-1): if (arr[i-1]<arr[i] and arr[i]>arr[i+1]...
output
1
92,796
12
185,593
Provide tags and a correct Python 3 solution for this coding contest problem. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p with length at least 2. * Among all such su...
instruction
0
92,797
12
185,594
Tags: greedy, two pointers Correct Solution: ``` t = int(input()) for _ in range(t): n1 = int(input()) a= list(map(int,input().split())) g = [] inc = -1 c=0 n=0 # f = a[i-1] for i in range(1,n1): if a[i]>a[i-1]: if n>0: g.append(f) # g....
output
1
92,797
12
185,595
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,798
12
185,596
Yes
output
1
92,798
12
185,597
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,799
12
185,598
Yes
output
1
92,799
12
185,599
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,800
12
185,600
Yes
output
1
92,800
12
185,601
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,801
12
185,602
Yes
output
1
92,801
12
185,603
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,802
12
185,604
No
output
1
92,802
12
185,605
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,803
12
185,606
No
output
1
92,803
12
185,607
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,804
12
185,608
No
output
1
92,804
12
185,609
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Given a permutation p of length n, find its subsequence s_1, s_2, …, s_k of length at least 2 such that: * |s_1-s_2|+|s_2-s_3|+…+|s_{k-1}-s_k| is as big as possible over all subsequences of p...
instruction
0
92,805
12
185,610
No
output
1
92,805
12
185,611
Provide tags and a correct Python 3 solution for this coding contest problem. Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated). The weight of a is defined as the ma...
instruction
0
92,822
12
185,644
Tags: binary search, constructive algorithms, data structures, greedy, two pointers Correct Solution: ``` class Fenwick: def __init__(self, size): self.size = size self.tree = [0] * (size + 1) def add(self, idx, val): idx = int(idx) while idx <= self.size: self.tree[...
output
1
92,822
12
185,645
Provide tags and a correct Python 3 solution for this coding contest problem. Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated). The weight of a is defined as the ma...
instruction
0
92,823
12
185,646
Tags: binary search, constructive algorithms, data structures, greedy, two pointers Correct Solution: ``` from sys import stdin def bitadd(a,w,bit): x = a while x <= (len(bit)-1): bit[x] += w x += x & (-1 * x) def bitsum(a,bit): ret = 0 x = a while x > 0: ret += bit[x]...
output
1
92,823
12
185,647
Provide tags and a correct Python 3 solution for this coding contest problem. Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated). The weight of a is defined as the ma...
instruction
0
92,824
12
185,648
Tags: binary search, constructive algorithms, data structures, greedy, two pointers Correct Solution: ``` from sys import stdin def bitadd(a,w,bit): x = a while x <= (len(bit)-1): bit[x] += w x += x & (-1 * x) def bitsum(a,bit): ret = 0 x = a while x > 0: ret += bit[x]...
output
1
92,824
12
185,649
Provide tags and a correct Python 3 solution for this coding contest problem. Let a_1, …, a_n be an array of n positive integers. In one operation, you can choose an index i such that a_i = i, and remove a_i from the array (after the removal, the remaining parts are concatenated). The weight of a is defined as the ma...
instruction
0
92,825
12
185,650
Tags: binary search, constructive algorithms, data structures, greedy, two pointers Correct Solution: ``` from sys import stdin def bitadd(a,w,bit): x = a while x <= (len(bit)-1):bit[x] += w;x += x & (-1 * x) def bitsum(a,bit): ret = 0;x = a while x > 0:ret += bit[x];x -= x & (-1 * x) return ret cla...
output
1
92,825
12
185,651
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,826
12
185,652
Tags: math, sortings Correct Solution: ``` for _ in range(int(input())): input();a = list(map(int, input().split())) s = sum(a) if s==0:print('NO') else: print('YES') if s>0: print(*sorted(a, reverse=True)) else: print(*sorted(a)) ```
output
1
92,826
12
185,653
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,827
12
185,654
Tags: math, sortings Correct Solution: ``` t = int(input()) q = [] for i in range(t): n = int(input()) l = list(map(int, list(input().split()))) if sum(l) == 0: q.append(["NO"]) else: l.sort() q.append(["YES"]) if sum(l) > 0: q.append(l[::-1]) else: ...
output
1
92,827
12
185,655
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,828
12
185,656
Tags: math, sortings Correct Solution: ``` t = int(input()) for _ in range(t): n = int(input()) a = list(map(int, input().split())) if sum(a) == 0: print('NO') elif sum(a) > 0: print('YES') print(*sorted(a, reverse=True)) else: print('YES') print(*sorted(a)) ...
output
1
92,828
12
185,657
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,829
12
185,658
Tags: math, sortings Correct Solution: ``` t = int(input()) for _ in range(t): n = int(input()) a = list(sorted(map(int,input().split()))) def judge(a): cum = 0 for i in range(n): cum += a[i] if cum == 0: flag = True for k in range(i...
output
1
92,829
12
185,659
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,830
12
185,660
Tags: math, sortings Correct Solution: ``` def function(): n=int(input()) a=list(map(int,input().split())) temp=[] b=[] flag=0 if sum(a)==0: print("NO") else: sum1=0 sum2=0 for i in a: if i>0: sum1=sum1+i temp.append...
output
1
92,830
12
185,661
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,831
12
185,662
Tags: math, sortings Correct Solution: ``` T = int( input() ) for t in range(T): n = int( input() ) st = input().split() A = [] s = 0 for i in range(n): A.append( int( st[i] ) ) s += A[i] if s == 0: print("NO") continue else: print("YES") if s > 0: A = sorted(A, reverse=True)...
output
1
92,831
12
185,663
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,832
12
185,664
Tags: math, sortings Correct Solution: ``` for test in range(int(input())): n = int(input()) a = list(map(int, input().split())) a.sort() if sum(a)==0: print("NO") elif sum(a)>0: print("YES") print(*a[::-1]) else: print("YES") print(*a) ```
output
1
92,832
12
185,665
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it contains the same values and each value appears the ...
instruction
0
92,833
12
185,666
Tags: math, sortings Correct Solution: ``` t = int(input()) for i in range(t): n = int(input()) a = list(map(int, input().split())) arr = [] if sum(a) == 0: print("NO") elif sum(a) > 0: a.sort(reverse=True) print("YES") print(*a) elif sum(a) < 0: a.sort()...
output
1
92,833
12
185,667
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,834
12
185,668
Yes
output
1
92,834
12
185,669
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,835
12
185,670
Yes
output
1
92,835
12
185,671
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,836
12
185,672
Yes
output
1
92,836
12
185,673
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,837
12
185,674
Yes
output
1
92,837
12
185,675
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,838
12
185,676
No
output
1
92,838
12
185,677
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,839
12
185,678
No
output
1
92,839
12
185,679
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,840
12
185,680
No
output
1
92,840
12
185,681
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 of n integers a_1,a_2,...,a_n. You have to create an array of n integers b_1,b_2,...,b_n such that: * The array b is a rearrangement of the array a, that is, it conta...
instruction
0
92,841
12
185,682
No
output
1
92,841
12
185,683
Provide tags and a correct Python 3 solution for this coding contest problem. Note that the memory limit is unusual. You are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Let's call a set of integers S such that S βŠ† \{1, 2, 3, ..., n\} strange, if, for every element i of S, the foll...
instruction
0
92,859
12
185,718
Tags: flows, math Correct Solution: ``` # Author: yumtam # Created at: 2021-03-02 20:19 def main(): n = int(input()) A = [int(t) for t in input().split()] cost = [int(t) for t in input().split()] g = Flow(n+2) s, t = n, n+1 last = [-1] * 101 for i, x in enumerate(A): for d in ...
output
1
92,859
12
185,719
Provide tags and a correct Python 3 solution for this coding contest problem. Note that the memory limit is unusual. You are given an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Let's call a set of integers S such that S βŠ† \{1, 2, 3, ..., n\} strange, if, for every element i of S, the foll...
instruction
0
92,860
12
185,720
Tags: flows, math Correct Solution: ``` from collections import deque class Dinic: def __init__(self, N): self.N = N self.G = [[] for i in range(N)] # 1方向 def add_edge(self, fr, to, cap): forward = [to, cap, None] forward[2] = backward = [fr, 0, forward] self.G[fr].a...
output
1
92,860
12
185,721
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 an integer n and two sequences a_1, a_2, ..., a_n and b_1, b_2, ..., b_n. Let's call a set of integers S such that S βŠ† \{1, 2, 3, ..., n\} ...
instruction
0
92,864
12
185,728
No
output
1
92,864
12
185,729
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,099
12
186,198
Tags: brute force, dp, implementation Correct Solution: ``` n=int(input()) l=list(map(int,input().split())) c=1 t=[] f=0 for i in range(0,n-1): if (l[i]<=l[i+1]): c=c+1 else: f=1 c=1 t.append(c) if f==0: print(c) else: print(max(t)) ```
output
1
93,099
12
186,199
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,100
12
186,200
Tags: brute force, dp, implementation Correct Solution: ``` n = int(input()) c = list(map(int, input().split())) most = 0 tmp = 0 for i, num in enumerate(c): if num >= c[i - 1] and i > 0: tmp += 1 else: if tmp > most: most = tmp tmp = 0 if tmp > most: most = tmp print(most+1) ```
output
1
93,100
12
186,201
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,101
12
186,202
Tags: brute force, dp, implementation Correct Solution: ``` n = int(input()) s = list(map(int, input().split(' '))) m = 1 l = 1 for i in range(n-1): if s[i] <= s[i+1]: l += 1 m = max(l, m) else: m = max(l, m) l = 1 print(m) ```
output
1
93,101
12
186,203
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,102
12
186,204
Tags: brute force, dp, implementation Correct Solution: ``` n=int(input()) s=list(map(int,input().split())) number=[] c=0 for i in range(n-1): if s[i]<=s[i+1]: c+=1 else: number.append(c+1) c=0 number.append(c+1) if c+1==n: print(c+1) else: result=sorted(number) print(result[...
output
1
93,102
12
186,205
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,103
12
186,206
Tags: brute force, dp, implementation Correct Solution: ``` n = int(input()) a = [0] + [int(s) for s in input().split()] dp = [0] * (n+2) for i in range(1, n+1): if a[i] >= a[i-1]: dp[i] = dp[i-1] + 1 else: dp[i] = 1 print(max(dp)) ```
output
1
93,103
12
186,207
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,104
12
186,208
Tags: brute force, dp, implementation Correct Solution: ``` n=input() l=input().split() count=1 ans=0 for i in range (0,int(n)-1): if(int(l[i])<=int(l[i+1])): count=count+1 else: if(count>ans): ans=count count=1 print(max(ans,count)) ```
output
1
93,104
12
186,209
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,105
12
186,210
Tags: brute force, dp, implementation Correct Solution: ``` n = int(input()) l = list(map(int, input().split())) ans, cnt = 0, 1 for i in range(1, n): if l[i] >= l[i - 1]: cnt -= -1 else: ans = max(ans, cnt) cnt = 1 ans = max(ans, cnt) print(ans) ```
output
1
93,105
12
186,211
Provide tags and a correct Python 3 solution for this coding contest problem. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know the length of the maximum non-decreasing subsegm...
instruction
0
93,106
12
186,212
Tags: brute force, dp, implementation Correct Solution: ``` n = int(input()) a = list(map(int,input().split(' '))) tmp = 1 max_tmp = 1 for i in range(n-1): if a[i] <= a[i+1]: tmp+=1 if tmp > max_tmp: max_tmp = tmp # print(a[i]) else: tmp = 1 print(max_tmp) ```
output
1
93,106
12
186,213
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know t...
instruction
0
93,107
12
186,214
Yes
output
1
93,107
12
186,215
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know t...
instruction
0
93,108
12
186,216
Yes
output
1
93,108
12
186,217
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Kefa decided to make some money doing business on the Internet for exactly n days. He knows that on the i-th day (1 ≀ i ≀ n) he makes ai money. Kefa loves progress, that's why he wants to know t...
instruction
0
93,109
12
186,218
Yes
output
1
93,109
12
186,219