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
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,338
12
28,676
Yes
output
1
14,338
12
28,677
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,339
12
28,678
Yes
output
1
14,339
12
28,679
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,340
12
28,680
Yes
output
1
14,340
12
28,681
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,341
12
28,682
No
output
1
14,341
12
28,683
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,342
12
28,684
No
output
1
14,342
12
28,685
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,343
12
28,686
No
output
1
14,343
12
28,687
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Ashish has n elements arranged in a line. These elements are represented by two integers a_i β€” the value of the element and b_i β€” the type of the element (there are only two possible types: 0 ...
instruction
0
14,344
12
28,688
No
output
1
14,344
12
28,689
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,345
12
28,690
Tags: greedy Correct Solution: ``` t = int(input()) while t: n = int(input()) l = [int(x) for x in input().split()] assert len(l) == 2*n c = [0]*2*n o = [] for i in range(2*n): if c[i]==1: o.append(str(l[i])) ...
output
1
14,345
12
28,691
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,346
12
28,692
Tags: greedy Correct Solution: ``` import sys def input(): return sys.stdin.readline().rstrip() def input_split(): return [int(i) for i in input().split()] testCases = int(input()) answers = [] for _ in range(testCases): #take input n = int(input()) arr = input_split() found = [False for i in range(n+1)] ans ...
output
1
14,346
12
28,693
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,347
12
28,694
Tags: greedy Correct Solution: ``` n=int(input()) for _ in range(n): m=int(input()) ar=list(map(int,input().split())) x=[] for i in ar: if i not in x: x.append(i) p=len(x) for i in range(p): print(x[i],end=' ') ```
output
1
14,347
12
28,695
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,348
12
28,696
Tags: greedy Correct Solution: ``` t = int(input()) for i in range(t): length = input() inp = input() inp_split = inp.split(" ") numbers = [int(num) for num in inp_split] check = [] for i in numbers: if i not in check: check.append(i) final1 = [str(i) for i in check] ...
output
1
14,348
12
28,697
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,349
12
28,698
Tags: greedy Correct Solution: ``` t = int(input()) for _ in range(t): s = set() n = int(input()) a = list(map(int,input().split())) for i in a: if i not in s: s.add(i) print(i,end = ' ') print() ```
output
1
14,349
12
28,699
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,350
12
28,700
Tags: greedy Correct Solution: ``` c=int(input()) for j in range(c): n=int(input()) l=list(map(int,input().split())) d=list(dict.fromkeys(l)) for i in d: if i in l: print(i,end=" ") print() ```
output
1
14,350
12
28,701
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,351
12
28,702
Tags: greedy Correct Solution: ``` t = int(input()) #the number of test cases for k in range(t): n = int(input()) #the length of permutation a = list(map(int, input().split())) p = [] #the oiginal permuaion for i in range(n * 2): if a[i] not in p: p.append(a[i]) for i in...
output
1
14,351
12
28,703
Provide tags and a correct Python 3 solution for this coding contest problem. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1], [2, 2, 1, 4] are not. There was a permutatio...
instruction
0
14,352
12
28,704
Tags: greedy Correct Solution: ``` for T in range(int(input())): n=int(input()) arr=[int(i) for i in input().split()] c=[0 for i in range(n+1)] ans=[] for i in arr: if c[i]==0: ans.append(str(i)) c[i]=1 print(' '.join(ans)) ```
output
1
14,352
12
28,705
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,353
12
28,706
Yes
output
1
14,353
12
28,707
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,354
12
28,708
Yes
output
1
14,354
12
28,709
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,355
12
28,710
Yes
output
1
14,355
12
28,711
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,356
12
28,712
Yes
output
1
14,356
12
28,713
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,357
12
28,714
No
output
1
14,357
12
28,715
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,358
12
28,716
No
output
1
14,358
12
28,717
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,359
12
28,718
No
output
1
14,359
12
28,719
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. A permutation of length n is a sequence of integers from 1 to n of length n containing each number exactly once. For example, [1], [4, 3, 5, 1, 2], [3, 2, 1] are permutations, and [1, 1], [0, 1]...
instruction
0
14,360
12
28,720
No
output
1
14,360
12
28,721
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,369
12
28,738
Tags: constructive algorithms, greedy Correct Solution: ``` import sys input = sys.stdin.readline def main(): n = int(input()) alst = list(map(int, input().split())) cnt = [0 for _ in range(n + 1)] for a in alst: cnt[a] += 1 if max(cnt) > (n + 1) / 2: print(-1) return ...
output
1
14,369
12
28,739
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,370
12
28,740
Tags: constructive algorithms, greedy Correct Solution: ``` def calc(A): N = len(A) if N == 1:return 0 X = [0] * N for a in A:X[a] += 1 if max(X) > (N + 1) // 2:return -1 Y = [0] * N;Y[A[0]] += 1;Y[A[-1]] += 1 for a, b in zip(A, A[1:]): if a == b:Y[a] += 2 su, ma = sum(Y), max(Y)...
output
1
14,370
12
28,741
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,371
12
28,742
Tags: constructive algorithms, greedy Correct Solution: ``` import sys input = sys.stdin.readline t=int(input()) for tests in range(t): n=int(input()) A=list(map(int,input().split())) C=[0]*(n+1) for a in A: C[a]+=1 MAX=-1 MAXI=-1 for i in range(n+1): if C[i]>MAX: ...
output
1
14,371
12
28,743
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,372
12
28,744
Tags: constructive algorithms, greedy Correct Solution: ``` from collections import Counter for _ in range(int(input())): n = int(input()) A = list(map(int, input().split())) if max(Counter(A).values()) > (n + 1) // 2: print(-1) else: k = 0 cnt = Counter() cnt[A[0]] += 1 ...
output
1
14,372
12
28,745
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,373
12
28,746
Tags: constructive algorithms, greedy Correct Solution: ``` T, = map(int, input().split()) for _ in range(T): N, = map(int, input().split()) X = list(map(int, input().split())) d = [0] * (N+1) for x in X: d[x] += 1 if max(d) > (N+1)//2: print(-1) continue L = [] stack...
output
1
14,373
12
28,747
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,374
12
28,748
Tags: constructive algorithms, greedy Correct Solution: ``` import sys input = sys.stdin.readline for _ in range(int(input())): n = int(input()) N = n a = list(map(int,input().split())) a = [a[i]-1 for i in range(n)] E = [] cnt = [0 for i in range(n)] L = 0 for i in range(1,n): ...
output
1
14,374
12
28,749
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,375
12
28,750
Tags: constructive algorithms, greedy Correct Solution: ``` #!/usr/bin/env python import os import sys from io import BytesIO, IOBase def main(): for _ in range(int(input())): n = int(input()) a = list(map(int,input().split())) cnt = 0 aCnt = [0] * n for i in range(n): ...
output
1
14,375
12
28,751
Provide tags and a correct Python 3 solution for this coding contest problem. To help those contestants who struggle a lot in contests, the headquarters of Codeforces are planning to introduce Division 5. In this new division, the tags of all problems will be announced prior to the round to help the contestants. The ...
instruction
0
14,376
12
28,752
Tags: constructive algorithms, greedy Correct Solution: ``` # region fastio # from https://codeforces.com/contest/1333/submission/75948789 import sys, io, os BUFSIZE = 8192 class FastIO(io.IOBase): newlines = 0 def __init__(self, file): self._fd = file.fileno() self.buffer = io.BytesIO() ...
output
1
14,376
12
28,753
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,576
12
29,152
Tags: constructive algorithms, greedy Correct Solution: ``` import itertools import math def main(): n, k = map(int, input().split()) a = 1 b = n res = [] for i in range(k - 1): if i % 2: res.append(a) a += 1 else: res.append(b) b -= 1 if k % 2: res += range(b, a - 1, -1) else: res += range(...
output
1
14,576
12
29,153
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,577
12
29,154
Tags: constructive algorithms, greedy Correct Solution: ``` n, k = map(int, input().split()) res = [] for i in range(1, k+2): if i % 2 == 1: res.append((i+1) // 2) else: res.append(k + 2 - (i//2)) res += list(range(k+2, n+1)) print(*res) ```
output
1
14,577
12
29,155
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,578
12
29,156
Tags: constructive algorithms, greedy Correct Solution: ``` from sys import exit n,k = map(int,input().split()) if n<=2: print(*[i for i in range(1,n+1)]) exit() else: d = [1] for i in range(n+1): if k<=0: break if i%2==0: d.append(k+d[-1]) k-=1 else: d.append(d[-1]-k) k-=1 if len(d)==n: pr...
output
1
14,578
12
29,157
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,579
12
29,158
Tags: constructive algorithms, greedy Correct Solution: ``` entry = input().split() p = int(entry[0]) k = int(entry[1]) forward = 1 backward = k + 1 answer = [] for controller in range((k//2) + 1): answer.append(str(forward)) if forward != backward: answer.append(str(backward)) forward += 1 ...
output
1
14,579
12
29,159
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,580
12
29,160
Tags: constructive algorithms, greedy Correct Solution: ``` n,k = input().split() answer = [] answer.append(1) appendVar = 1 lowVar = 2 highVar = 1 + int(k) for i in range(1, int(k) + 1): if i % 2 == 1: appendVar = highVar highVar -= 1 answer.append(appendVar) else: appendVar = lowVar lowVar +=...
output
1
14,580
12
29,161
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,581
12
29,162
Tags: constructive algorithms, greedy Correct Solution: ``` n,k=input().split() n=int(n) k=int(k)-1 b=[] s=(k+3)//2 b.append(s) i=0 if k%2==0: i=1 else: i=-1 while k>-1: s=s+i b.append(s) if i>0: i=-1*i-1 else: i=-1*i+1 k-=1 while s<n: s+=1 b.append(s) for d in range(len(b)): print(b[d],end=' ') ```
output
1
14,581
12
29,163
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,582
12
29,164
Tags: constructive algorithms, greedy Correct Solution: ``` f = input() n , k = map(int , f.split(' ')) x = n y = 1 for i in range(k): if(i % 2 == 0): print(x, end=" ") x -= 1 else: print(y, end=" ") y += 1 bas = 0 t = 0 if k % 2 == 0: bas = y t = 1 else: bas = x ...
output
1
14,582
12
29,165
Provide tags and a correct Python 3 solution for this coding contest problem. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task is to find such permutation p of length n, tha...
instruction
0
14,583
12
29,166
Tags: constructive algorithms, greedy Correct Solution: ``` # Description of the problem can be found at http://codeforces.com/problemset/problem/482/A n, k = map(int, input().split()) l_n = list() h = n l = 1 for i in range(n): if i < k: if i % 2 == 0: l_n.append(i // 2 + 1) l = ...
output
1
14,583
12
29,167
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,584
12
29,168
Yes
output
1
14,584
12
29,169
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,585
12
29,170
Yes
output
1
14,585
12
29,171
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,586
12
29,172
Yes
output
1
14,586
12
29,173
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,587
12
29,174
Yes
output
1
14,587
12
29,175
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,588
12
29,176
No
output
1
14,588
12
29,177
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,589
12
29,178
No
output
1
14,589
12
29,179
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,590
12
29,180
No
output
1
14,590
12
29,181
Evaluate the correctness of the submitted Python 3 solution to the coding contest problem. Provide a "Yes" or "No" response. Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers not larger than n. We'll denote as n the length of permutation p1, p2, ..., pn. Your task...
instruction
0
14,591
12
29,182
No
output
1
14,591
12
29,183
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,122
12
30,244
Tags: implementation Correct Solution: ``` n = int(input()) a = sorted([*map(int, input().split())]) print (min(a[-1] - a[1], a[-2] - a[0])) ```
output
1
15,122
12
30,245
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,123
12
30,246
Tags: implementation Correct Solution: ``` n=int(input()) arr=list(map(int,input().split())) arr.sort() left=arr[1]-arr[0] right=arr[-1]-arr[-2] if(right>left): print(arr[-2]-arr[0]) elif(left>right): print(arr[-1]-arr[1]) elif(left==right): print(arr[-1]-arr[1]) ```
output
1
15,123
12
30,247
Provide tags and a correct Python 3 solution for this coding contest problem. You are given an array a consisting of n integer numbers. Let instability of the array be the following value: max_{i = 1}^{n} a_i - min_{i = 1}^{n} a_i. You have to remove exactly one element from this array to minimize instability of the...
instruction
0
15,124
12
30,248
Tags: implementation Correct Solution: ``` x = int(input()) m = [] for i in input().split(): m.append(int(i)) min = m[0] max = m[0] for i in range(x): if m[i] < min: min = m[i] if m[i] > max: max = m[i] m.remove(min) x -= 1 min2 = m[0] for i in range(x): if min2 > m[i]: min2 = m[...
output
1
15,124
12
30,249