s_id
stringlengths
10
10
p_id
stringlengths
6
6
u_id
stringlengths
10
10
date
stringlengths
10
10
language
stringclasses
1 value
original_language
stringclasses
11 values
filename_ext
stringclasses
1 value
status
stringclasses
1 value
cpu_time
int64
0
100
memory
stringlengths
4
6
code_size
int64
15
14.7k
code
stringlengths
15
14.7k
problem_id
stringlengths
6
6
problem_description
stringlengths
358
9.83k
input
stringlengths
2
4.87k
output
stringclasses
807 values
__index_level_0__
int64
1.1k
1.22M
s596424645
p02255
u674981332
1583144488
Python
Python3
py
Accepted
20
5596
222
n = int(input()) a = list(map(int, input().split())) for i in range(n): key = a[i] j = i - 1 while j >= 0 and a[j] > key: a[j+1] = a[j] j -= 1 a[j+1] = key print(" ".join(map(str, a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,282
s053057332
p02255
u800532528
1583116565
Python
Python3
py
Accepted
20
5984
276
N = int(input()) A = list(map(int, input().split())) for i in range(1, N): print(*A) for j in range(i): if A[j] > A[i]: break else: continue tmp = A[i] for k in range(i, j, -1): A[k] = A[k - 1] A[j] = tmp print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,283
s823814685
p02255
u808372529
1583054203
Python
Python3
py
Accepted
20
5976
204
n = int(input()) a = list(map(int,input().split())) print(*a) for i in range(1,n): for j in range(i): p = i-j if a[p] < a[p-1]: a[p], a[p-1] = a[p-1], a[p] print (*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,284
s590031770
p02255
u178746564
1582999033
Python
Python3
py
Accepted
20
5604
323
N=int(input()) A=list(map(int,input().split())) def insertionSort(N,A): print(' '.join(map(str,A))) for i in range(1,N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j=j-1 A[j+1]=v print(' '.join(map(str,A))) insertionSort(N,...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,285
s566311595
p02255
u127335036
1582986726
Python
Python3
py
Accepted
20
5604
341
n=int(input()) a=list(map(int, input().split())) def insertion(a:list, n:int) -> None: if not isinstance(a, list): return None for i in range(n): v=a[i] j=i-1 while j >= 0 and a[j] > v: a[j+1]=a[j] j-=1 a[j+1]=v print(" ".join(map(str, a...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,286
s091433687
p02255
u392923641
1582920863
Python
Python3
py
Accepted
20
5604
317
import sys input = sys.stdin.readline def print_vec(vec): print(" ".join(map(str, vec))) N = int(input()) A = list(map(int, input().split())) for i in range (len (A)): key = A [i] j = i - 1 while j >= 0 and A [j] > key: A [j + 1] = A [j] j -= 1 A [j + 1] = key print_vec(A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,287
s400978434
p02255
u185907219
1582696725
Python
Python3
py
Accepted
20
5984
238
N = int(input()) nums = list(map(int, input().split())) for i in range(len(nums)): num = nums[i] j = i - 1 while j >= 0 and nums[j] > num: nums[j + 1] = nums[j] j -= 1 nums[j + 1] = num print(*nums)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,288
s265314789
p02255
u230072054
1582617817
Python
Python3
py
Accepted
40
6308
343
N = int(input()) data = list(map(int, input().split())) for i in range(N): tmp = data[i] j = i - 1 while j >= 0 and data[j] > tmp: data[j+1] = data[j] j -= 1 data[j+1] = tmp for j in range(N): print("%d" %(data[j]), end="") if j != N-1: print(" "...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,289
s066822757
p02255
u920279959
1582597433
Python
Python3
py
Accepted
20
5976
191
n = int(input()) a = list(map(int, input().split())) print(*a) for i in range(1,n): for j in range(i,0,-1): if a[j]<a[j-1]: a[j], a[j-1] = a[j-1], a[j] print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,290
s464572561
p02255
u556798528
1582592908
Python
Python3
py
Accepted
20
5604
283
def insertion_sort(A,N): prin(A) for i in range(1,N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v prin(A) def prin(A): print(' '.join(list(map(str, A)))) N = int(input()) A = [int(i) for i in input().split(' ')] insertion_sort(A,N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,291
s968092174
p02255
u790542161
1582524468
Python
Python3
py
Accepted
20
5604
827
N = int(input()) A = list(map(int, input().split())) #%% def insertionSort(A, N): for i in range(1, N): v = A[i] # これからソートしたい1つの数字(i番目) j = i - 1 # ソート済み(i-1番目まで)のインデックス print(' '.join(map(str, A))) # j以下のものを順番に右にずらしていきながら、挿入する値のインデックスを決める while j >= 0 and A[j] > v: ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,292
s066056148
p02255
u476408985
1582501111
Python
Python3
py
Accepted
30
5976
469
N = int(input()) num_list = list(map(int,input().split())) for n in range(N): if n == N-1: print(num_list[n]) else: print(num_list[n],end=" ") for i in range(1,N): v = num_list[i] j = i-1 while j >= 0 and num_list[j] > v: num_list[j+1] = num_list[j] j -= 1 ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,293
s193488950
p02255
u670660757
1582498836
Python
Python3
py
Accepted
20
5608
312
n = int(input()) a = [int(x) for x in input().split()] print(' '.join([str(x) for x in a])) for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j + 1] = a[j] j -= 1 a[j + 1] = v print(' '.join([str(x) for x in a]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,294
s861548504
p02255
u577755795
1582474380
Python
Python3
py
Accepted
20
5596
240
N = int(input()) nums = input() print(nums) A = list(map(int, nums.split())) for i in range(1,N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,295
s640974149
p02255
u891183253
1582446518
Python
Python3
py
Accepted
20
5980
324
N = int(input()) num_list = [int(item) for item in input().split()] def insertionSort(A, N): print(*A) for i in range(1, N): v = A[i] j = i -1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(*A) insertionSort(num_list,...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,296
s775469861
p02255
u573071241
1582355420
Python
Python3
py
Accepted
20
5976
197
n = int(input()) l = list(map(int, input().split(" "))) for i, v in enumerate(l): j = i - 1 while j >= 0 and l[j] > v: l[j + 1] = l[j] j -= 1 l[j + 1] = v print(*l)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,297
s840487832
p02255
u805852387
1582348419
Python
Python3
py
Accepted
20
5980
258
def insertsort(a,n): for i in range(1,n): v=a[i] j=i-1 while j>=0 and a[j]>v: a[j+1]=a[j] j-=1 a[j+1]=v print(*a) N=int(input()) A=list(map(int,input().split())) print(*A) insertsort(A,N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,298
s492165000
p02255
u992758171
1582250279
Python
Python3
py
Accepted
20
5608
262
n = int(input()) a = [int(i) for i in input().split(" ")] print(" ".join([str(i) for i in a])) for i in range(1, n, 1): for j in range(i): if a[i] < a[j]: a.insert(j, a[i]) a.pop(i+1) print(" ".join([str(i) for i in a]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,299
s128145671
p02255
u222861595
1582166891
Python
Python3
py
Accepted
20
5612
253
N, *A = map(int, open(0).read().split()) print(' '.join([str(a) for a in A])) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j+1] = v print(' '.join([str(a) for a in A]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,300
s630540270
p02255
u951508466
1582013603
Python
Python3
py
Accepted
20
5604
250
n = int(input()) A = [int(s) for s in input().split()] print(' '.join(map(str, A))) for i in range(1,n): v = A[i] j = i - 1 while (j >= 0 and A[j] > v): A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,301
s767347211
p02255
u479010679
1581836939
Python
Python3
py
Accepted
20
5612
340
import sys def insertionSort(A, N): print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j-=1 A[j+1] = v print(' '.join(map(str, A))) N = int(input()) A = list(map(int, input().split())) i...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,302
s033692272
p02255
u217408867
1581836283
Python
Python3
py
Accepted
20
5608
227
N = int(input()) A = list(map(int, input().split())) for i in range(N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join([str(i) for i in A]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,303
s588919091
p02255
u217435805
1581664555
Python
Python3
py
Accepted
20
5608
250
n = int(input()) a = list(map(int, input().split())) for i in range(n): temp = a[i] j = i - 1 while j >= 0 and a[j] > temp: a[j+1] = a[j] j -= 1 a[j+1] = temp a_str = [str(s) for s in a] print(' '.join(a_str))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,304
s353556142
p02255
u123017074
1581648660
Python
Python3
py
Accepted
20
5984
338
def main(): N = int(input()) A = list(map(int, input().split())) insertionSort(A, N) def insertionSort(A, N): print(*A) for i in range(1, N): v = A[i] j = i - 1 while (0 <= j) and (v < A[j]): A[j + 1] = A[j] j -= 1 A[j + 1] = v p...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,305
s853426726
p02255
u674150838
1581578608
Python
Python3
py
Accepted
20
5608
284
N = int(input()) A = input().split() print(" ".join(A)) A = [int(l) for l in A] for i in range(1,N): v = A[i] j = i-1 while j>=0 and A[j] >v: A[j+1] = A[j] j -=1 A[j+1] = v A = [str(l) for l in A] print(" ".join(A)) A = [int(l) for l in A]
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,306
s614456898
p02255
u924587741
1581514342
Python
Python3
py
Accepted
30
5984
239
N=int(input()) A=list(int(x) for x in input().split()) for i in range(N): v=A[i] j=i-1 while j>=0 and A[j]>v: A[j+1]=A[j] j-=1 A[j+1]=v for i in range(N-1): print(A[i],end=" ") print(A[N-1])
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,307
s768429926
p02255
u481775069
1581502156
Python
Python3
py
Accepted
20
5980
208
N = int(input()) A = list(map(int,input().split())) i = 0 k = 0 for i in range(len(A)): v = A[i] j = i-1 while j>=0 and A[j]>v: A[j+1] = A[j] j -= 1 A[j+1] = v print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,308
s018542383
p02255
u715809280
1581501503
Python
Python3
py
Accepted
30
5980
450
# insertionSort(A, N) // N個の要素を含む0-オリジンの配列A def InsertionSort(A, N): for i in range(N): v = A[i] j = i - 1 while(j >= 0 and A[j] > v): A[j+1] = A[j] j-=1 A[j+1] = v print(*A) N = int(input()) A = list(map(int, input().split())) # 「1 2 3…」のような配列入力 # print(*A) # リストの出力を...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,309
s650263125
p02255
u044232230
1581424244
Python
Python3
py
Accepted
20
5608
471
N = int(input()) A = list(map(int,input().split())) print(' '.join([str(a) for a in A])) for i in range(1,N): key = A[i] j = i-1 # j=0で先頭まで来たらもう比較しない while j>=0 and A[j] > key: # より小さい項と比較する A[j+1] = A[j] j -= 1 # keyの位置は確定したので代入(while抜ける前にj-=1されているのでA[j+1]) A[j...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,310
s875671157
p02255
u357050809
1581345358
Python
Python3
py
Accepted
20
5604
289
num = int(input()) an = [ int(i) for i in input().split()] print(" ".join([str(n) for n in an])) for i in range(1, len(an)): v = an[i] j = i - 1 while j >= 0 and an[j] > v: an[j+1] = an[j] j = j - 1 an[j+1] = v print(" ".join([str(n) for n in an]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,311
s248215010
p02255
u570282993
1581140341
Python
Python3
py
Accepted
30
5608
260
N = int(input()) A = list(map(int,input().split())) print(" ".join([str(a) for a in A])) for i in range(1,N): v = A[i] j = i-1 while A[j] > v and j >= 0: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join([str(a) for a in A]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,312
s537182397
p02255
u820842907
1581042320
Python
Python3
py
Accepted
20
5980
370
def InsertionSort(seq): print(*seq) for i in range(len(seq) - 1): j = i while j >= 0: if seq[j + 1] < seq[j]: seq[j + 1], seq[j] = seq[j], seq[j + 1] j -= 1 print(*seq) def main(): n = int(input()) seq = [int(a) for a i...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,313
s103362136
p02255
u642827960
1580991094
Python
Python3
py
Accepted
20
5604
424
#アルゴリズムの実装 def insertionSort(A, N): for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join(map(str, A))) #入力dataの挿入 input_N = int(input()) input_A = list(map(int, input().split())) print(" "....
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,314
s264562522
p02255
u220403312
1580932678
Python
Python3
py
Accepted
20
5976
471
# Algorithm and Data Structures 1 # Name: Ryuya Asada # ID: s1260064 def InsertionSort(A: list): for i in range(1, len(A)): key = A[i] j = i - 1 print(*A, sep=" ") while (j >= 0 and A[j] > key): A[j+1] = A[j] j -= 1 A[j+1] = key def main(): len...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,315
s326394869
p02255
u514854274
1580803778
Python
Python3
py
Accepted
30
5984
528
# 入力 n = int(input().rstrip()) data = list(map(int,input().split())) # ソート for i in range(1, n): for s in range(n): if s != n-1: print(data[s], end=" ") else: print(data[s]) min = i j = i-1 while j >= 0: if data[min] < data[j]: tmp = data[j] ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,316
s647084337
p02255
u925219592
1580709050
Python
Python3
py
Accepted
40
6316
437
def show(A): N = len(A) for i in range(N): if i : print(' ', end = '') print(A[i], end = '') print() def insertionSort(A, N): show(A) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j = j ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,317
s620846509
p02255
u156037302
1580708149
Python
Python3
py
Accepted
40
6316
533
def printData(data) : for i, value in enumerate(data) : if i > 0 : print(" ", end = "") print(value, end = "") print() def insertionSort(data, N) : for i in range(1, N) : target = data[i] j = i -1 while j >= 0 and target < data[j] : data[j...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,318
s617616347
p02255
u674824796
1580473529
Python
Python3
py
Accepted
30
5604
323
def main1(): N = int(input()) A = [int(_) for _ in input().split()] print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A))) main1...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,319
s869942433
p02255
u165528868
1580457662
Python
Python3
py
Accepted
30
5976
459
n = int(input()) numbers = input().split() numbers = [int(num) for num in numbers] def show(numbers): for i in range(len(numbers)): if i != len(numbers) - 1: print(numbers[i], end=" ") else: print(numbers[i]) for i in range(1, n): show(numbers) key = numbers[i] ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,320
s776544727
p02255
u990721773
1580394266
Python
Python3
py
Accepted
20
5608
291
x = int(input()) l_t = [int(i)for i in input().split()] print(' '.join([str(p) for p in l_t])) for i in range(1,x): v = l_t[i] j = i - 1 while j >= 0 and l_t[j] > v: l_t[j + 1] = l_t[j] j = j - 1 l_t[j + 1] = v print(' '.join([str(p) for p in l_t]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,321
s603670343
p02255
u953620631
1580391180
Python
Python3
py
Accepted
20
5608
412
def insertionSort(A, N): # N個の要素を含む0-オリジンの配列A for i in range(1, N): print(' '.join([str(p) for p in A])) v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j-=1 A[j+1] = v print(' '.join([str(p) for p in A])) n = int(input()) a_li...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,322
s532449644
p02255
u432267158
1580374673
Python
Python3
py
Accepted
20
5980
270
#insertion sort n = int(input()) A = list(map(int,input().split())) print(*A) for i in range(1,n): j = i while(j > 0): if A[j-1] > A[j]: A[j-1],A[j] = A[j],A[j-1] #SWAP j -= 1 else: break print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,323
s677359771
p02255
u363751425
1580313724
Python
Python3
py
Accepted
20
5980
200
N = int(input()) * A, = map(int, input().split()) for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j = j - 1 A[j + 1] = v print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,324
s550328237
p02255
u195611026
1580305293
Python
Python3
py
Accepted
20
5596
246
n = int(input()) a = list(map(int, input().split())) print(" ".join(map(str, a))) for i in range(1, n): v = a[i] j = i-1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(" ".join(map(str, a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,325
s693807688
p02255
u775171104
1580271320
Python
Python3
py
Accepted
20
5612
422
def InsertionSort(A): i = 0 j = 0 print(' '.join([str(x) for x in A])) for i in range(1, N): movenum = A[i] j = i - 1 while j >= 0 and movenum < A[j] : A[j+1] = A[j] j -= 1 A[j + 1] = movenum print(' '.join([str(x) ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,326
s562221381
p02255
u622912304
1579737016
Python
Python3
py
Accepted
20
5604
337
def insertionSort(A, N): for i in range(0, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A))) if __name__ == "__main__": N = int(input()) A = list(map(int, input().split())) inse...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,327
s246921879
p02255
u868954188
1579611284
Python
Python3
py
Accepted
20
5976
216
N = int(input()) li = list(map(int,input().split())) print(*li) for i in range(1,N): v = li[i] j = i - 1 while j >= 0 and li[j] > v: li[j+1] = li[j] j -= 1 li[j+1] = v print(*li)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,328
s621049648
p02255
u368398598
1579530249
Python
Python3
py
Accepted
20
5592
249
N = int(input()) A = list(map(int, input().split())) print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,329
s013494612
p02255
u675300855
1579525827
Python
Python3
py
Accepted
20
5596
313
N = int(input()) A = list(map(int, input().split())) s = '' for a in A: s += str(a) + ' ' print(s.rstrip()) for i in range(1, N): for j in range(0, i): if A[i] < A[j]: A.insert(j, A.pop(i)) break s = '' for a in A: s += str(a) + ' ' print(s.rstrip())
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,330
s581348206
p02255
u363619128
1579512276
Python
Python3
py
Accepted
20
5616
587
n = int(input()) a = list(map(int, input().split())) def insertion_sort(a, n): print(" ".join(map(str, a))) for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(" ".join(map(st...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,331
s566320235
p02255
u207085501
1579425320
Python
Python3
py
Accepted
20
5604
254
n = int(input()) A = list(map(int,input().split())) for i, a in enumerate(A): temp = a i -= 1 while i >= 0 and A[i] >temp: A[i+1] = A[i] A[i] = temp i -= 1 L=[str(a) for a in A] p = ' '.join(L) print(p)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,332
s279669801
p02255
u675149350
1579292434
Python
Python3
py
Accepted
30
5980
404
def InsertionSort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v for j in range(N): if j == N-1: print(A[j]) else: print(A[j], end=' ') ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,333
s709329862
p02255
u403179723
1579267739
Python
Python3
py
Accepted
20
5604
350
def main(): N = int(input()) A = list(map(int, input().split(' '))) print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join(map(str, A))) if __nam...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,334
s455473536
p02255
u074820425
1579258599
Python
Python3
py
Accepted
20
5604
362
def insertingSort(a, n): for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and v < a[j]: a[j+1] = a[j] j -= 1 a[j+1] = v print(' '.join(list(map(str, a)))) n = int(input().strip()) a = list(map(int, input().strip().split())) print(' '.joi...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,335
s601599712
p02255
u473265737
1579011886
Python
Python3
py
Accepted
20
5604
330
def insertion_sort(A, N): print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i -1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A))) N = int(input()) A = list(map(int, input().split())) insertion_s...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,336
s870206213
p02255
u839237319
1578833261
Python
Python3
py
Accepted
20
5600
498
#1_A def insertion_sort(a, n): for i in range(n-1): j = i i = i + 1 v = a[i] while j>=0 and a[j]>v: a[j+1] = a[j] j -= 1 a[j+1] = v pr = str(a[0]) for i in range(n-1): i = i + 1 pr += " " + str(a[i]) ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,337
s236783848
p02255
u670802622
1578737403
Python
Python3
py
Accepted
20
5596
278
N = int(input()) lst = list(map(int, input().split())) print(" ".join(list(map(str, lst)))) for i in range(1, N): v = lst[i] j = i - 1 while (j >= 0 and lst[j] > v): lst[j+1] = lst[j] j -= 1 lst[j+1] = v print(" ".join(list(map(str, lst))))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,338
s136344351
p02255
u850212751
1578616798
Python
Python3
py
Accepted
30
5980
335
n=int(input()) a=[int(i) for i in input().split()] def p(a, n): for i in range(n): if i==n-1: print(a[i],end='') else : print(a[i], end=' ') def f(a, n): for i in range(n): v = a[i] j = i-1 while (a[j] > v) & (j>=0): a[j+1] = a[j] j-=1 a[j+1] = v p(a, n) pr...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,339
s790641696
p02255
u089870160
1577868288
Python
Python3
py
Accepted
20
5608
271
N=int(input()) A=list(map(int,input().split())) def insertSort(A,N): for i in range(N): v=A[i] j= i-1 while j>=0 and A[j]>v: A[j+1]=A[j] j-=1 A[j+1]=v print(' '.join(list(map(str,A)))) insertSort(A,N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,340
s885345091
p02255
u893211338
1577728767
Python
Python3
py
Accepted
20
5984
404
from sys import stdin #stdin = open("input.txt") def insertionSort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j += -1 A[j+1] = v print(*A) if __name__ == "__main__": N = int(stdin.readline()) ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,341
s837291058
p02255
u634409340
1577722572
Python
Python3
py
Accepted
20
5976
394
def insertion_sort(array, n): for i in range(1, n): v = array[i] j = i - 1 while j >= 0 and v < array[j]: array[j + 1] = array[j] j -= 1 array[j + 1] = v print(*array) def main(): n = int(input()) a = [int(i) for i in input().split()] pri...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,342
s236160428
p02255
u957523223
1577712711
Python
Python3
py
Accepted
20
5976
210
input() *A, = map(int, input().split()) for i, a in enumerate(A): j = i - 1 while j >= 0 and a < A[j]: A[j + 1] = A[j] j -= 1 else: A[j + 1] = a print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,343
s641057860
p02255
u531262486
1577604739
Python
Python3
py
Accepted
20
5976
207
n = int(input()) a = list(map(int,input().split())) for i in range(0,n): v = a[i] j = i - 1 while 0 <= j and v < a[j]: a[j+1] = a[j] j = j - 1 a[j+1] = v print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,344
s183045396
p02255
u805848032
1577537654
Python
Python3
py
Accepted
20
5608
223
n = int(input()) arr = list(map(int, input().split())) for i in range(n): v = arr[i] j = i - 1 while j >= 0 and arr[j] > v: arr[j + 1] = arr[j] j -= 1 arr[j+1] = v print (" ".join([str(x) for x in arr]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,345
s725681366
p02255
u617002940
1577419537
Python
Python3
py
Accepted
20
5600
475
def insert_sort(A): a = list(A) print(' '.join(map(str, a))) for move_index in range(1, len(a)): compare_index = move_index -1 while compare_index >= 0 and a[compare_index] > a[move_index]: a[compare_index], a[move_index] = int(a[move_index]), int(a[compare_index]) co...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,346
s897009421
p02255
u132187835
1577262887
Python
Python3
py
Accepted
20
5604
246
N = int(input()) A = [int(i) for i in input().split()] print(" ".join(map(str, A))) for i in range(1,N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,347
s182068962
p02255
u981006779
1577200271
Python
Python3
py
Accepted
20
5600
392
def InsertionSort(a:list, n:int): for i in range(0,n): key = a[i] j = i - 1 while( j >= 0 and a[j] > key): a[j+1] = a[j] j = j - 1 a[j+1] = key print(" ".join(map(str,a))) return a def main(): n = int(input()) a = list(map(int, input().spl...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,348
s067408131
p02255
u820092408
1577110329
Python
Python3
py
Accepted
20
5984
211
n = int(input()) a = list(map(int, input().split())) print(*a) for i in range(1, n): v = a[i] j = i-1 while j >= 0 and a[j] > v: a[j+1] = a[j] j = j - 1 a[j+1] = v print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,349
s315874803
p02255
u902441873
1577109853
Python
Python3
py
Accepted
30
5980
322
def listShow(A): for i in range(len(A)): if(i<len(A)-1): print(A[i],end=' ') else: print(A[i]) def insertionSort(A,N): for i in range(1,N): j=i-1 while(j>=0 and A[j]>A[j+1]): A[j],A[j+1]=A[j+1],A[j] j-=1 listShow(A) n=int(input()) a=list(map(int,input().split())) listShow(a) insertionSort(a,n)...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,350
s983626463
p02255
u514112325
1577105548
Python
Python3
py
Accepted
20
5980
217
N = int(input()) A = [int(a) for a in input().split()] print(*A) for i in range(1, N): j = i-1 key = A[i] while j >= 0 and key <= A[j]: A[j+1] = A[j] j -= 1 A[j+1] = key print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,351
s393472958
p02255
u372478932
1577000252
Python
Python3
py
Accepted
30
5600
544
def print_list(a): out = '' for ai in a: out += str(ai) + ' ' else: out = out[:-1] print(out) def insertion_sort(n, a): for i in range(1, n): print_list(a) v = a[i] sorted_list_idx = i while sorted_list_idx > 0 and a[sorted_list_idx - 1] > v: ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,352
s259404001
p02255
u194126754
1576824342
Python
Python3
py
Accepted
20
5976
450
def InsertionSort(A, N): for i in range(N): v = A[i] # A[i]は未ソート部分の先頭 j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] # vよりも大きい要素を一つ右に移動させる j -= 1 # 比較する位置を移動 A[j+1] = v # 空いた部分にvを入れる print(*A) N = int(input()) A = list(map(int, inp...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,353
s055493129
p02255
u341505811
1576590433
Python
Python3
py
Accepted
20
5976
293
def insertionSort(a, n): for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j + 1] = a[j] j -= 1 a[j + 1] = v print(*a) n = int(input()) l = list(map(int, input().split())) print(*l) insertionSort(l, n)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,354
s013387482
p02255
u467644915
1576503066
Python
Python3
py
Accepted
20
5596
221
N = int(input()) A = list(map(int, input().split())) for i in range(0, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j-=1 A[j + 1] = v print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,355
s371496044
p02255
u064444227
1576460355
Python
Python3
py
Accepted
20
5596
225
n=int(input()) s=list(map(int,input().split())) S=map(str,s) print(' '.join(S)) for i in range(1,n): tmp=s[i] j=i-1 while j>=0 and tmp < s[j]: s[j+1]=s[j] j -= 1 s[j+1]=tmp S=map(str,s) print(' '.join(S))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,356
s519451440
p02255
u167152630
1576207002
Python
Python3
py
Accepted
20
5980
299
N = int(input()) working_list = list(map(int, input().split())) print(*working_list) for i in range(1, N): v = working_list[i] j = i - 1 while j >= 0 and working_list[j] > v: working_list[j+1] = working_list[j] j -= 1 working_list[j+1] = v print(*working_list)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,357
s488814829
p02255
u079849541
1576129980
Python
Python3
py
Accepted
30
5984
364
n = input() b = int(n) - 1 a = input().split() nlist = [int(i) for i in a] #calc func for j in range(int(n)): if j != 0: for c2 in reversed(range(0,j)): if nlist[c2] > nlist[j]: stk = nlist[c2] nlist[c2] = nlist[j] nlist[j] = stk j = j - 1 c2 = j - 1 #print func for i in range(int(b)): p...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,358
s036295308
p02255
u837878575
1575991515
Python
Python3
py
Accepted
30
5984
440
def InsertionSort(A,N): for i in range(1,N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j = j - 1 A[j+1] = v for j in range(0,N-1): print("{0} ".format(A[j]),end = '') print(A[N-1]) N = int(input()) A = list(map(i...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,359
s755092828
p02255
u212896844
1575966595
Python
Python3
py
Accepted
20
5976
364
def insertionSort(arr): for i in range(1, len(arr)): v = arr[i] j = i-1 print(*arr) while j >= 0 and v < arr[j] : arr[j+1] = arr[j] j -= 1 arr[j+1] = v print(*arr) n = int(input()) ls = list(m...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,360
s159231348
p02255
u258369794
1575874899
Python
Python3
py
Accepted
30
5988
634
def main(): n = int(input()) a = input().split() A = [] for i in range(n): A.append(int(a[i])) display(A) insertSort(A) def insertSort(A): for i in range(1,len(A)): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,361
s258643215
p02255
u225899281
1575854687
Python
Python3
py
Accepted
20
5604
246
N = int(input()) a = list(map(int,input().split(" "))) for i in range(N): v = a[i] j = i - 1 while(j >= 0) and (a[j]>v): a[j+1] = a[j] j -= 1 a[j+1] = v b = [str(n) for n in a] print(" ".join(b))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,362
s184205694
p02255
u400765446
1575808205
Python
Python3
py
Accepted
20
5600
206
n = int(input()) A = input().split() print(' '.join(A)) for i in range(1,n): for j in range(i,0,-1): if int(A[j]) < int(A[j-1]): A[j], A[j-1] = A[j-1], A[j] print(' '.join(A))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,363
s096430053
p02255
u235698505
1575808180
Python
Python3
py
Accepted
20
5984
382
def main(): # 個数を入力 num = int(input()) a = list(int(i) for i in input().split()) print(*a) insertSort(a) def insertSort(A): for i in range(1, len(A)): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,364
s864463817
p02255
u793684078
1575777274
Python
Python3
py
Accepted
20
5604
295
def insertionSort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join(map(str, A))) N = int(input()) A = list(map(int, input().split(' '))) insertionSort(A, N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,365
s230043852
p02255
u411550052
1575720852
Python
Python3
py
Accepted
20
5608
268
n=int(input()) A=list(map(int, input().split())) #A=input().split() print(" ".join([str(i) for i in A])) for i in range(1,len(A)): v=A[i] j=i-1 while j>=0 and A[j]>v: A[j+1]=A[j] j-=1 A[j+1]=v print(" ".join([str(i) for i in A]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,366
s748661088
p02255
u698652225
1575643320
Python
Python3
py
Accepted
20
5980
205
N = int(input()) A = list(map(int,input().split())) print(*A) for i in range(1,N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,367
s319726825
p02255
u481517137
1575622132
Python
Python3
py
Accepted
20
5600
206
n=int(input()) a=list(map(int,input().split())) print(" ".join(map(str,a))) for i in range(1,n): v=a[i] j=i-1 while j>=0 and a[j]>v: a[j+1]=a[j] j-=1 a[j+1]=v print(" ".join(map(str,a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,368
s756206163
p02255
u230220367
1575614290
Python
Python3
py
Accepted
20
5600
373
num = int(input()) list = list(map(int, input().split())) for i in range(num): v = list[i] if i == 0: list[0] = v else: j = i - 1 while j >= 0 and list[j] > v: list[j+1] = list[j] j -= 1 list[j+1] = v result = '' for i in range(num): ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,369
s512601963
p02255
u613278035
1575529511
Python
Python3
py
Accepted
40
6312
240
n = int(input()) A = list(map(int, input().split())) for j in range(n): d = A[j] i = j - 1 while i >= 0 and A[i] > d: A[i+1] = A[i] i -= 1 A[i+1] = d for i in range(n): if i: print(" ", end="") print(A[i], end="") print()
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,370
s239395190
p02255
u369455271
1575526302
Python
Python3
py
Accepted
30
5604
250
N = int(input()) A = [int(n) for n in input().split()] print(" ".join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(" ".join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,371
s790090136
p02255
u911405251
1575470561
Python
Python3
py
Accepted
40
6308
459
def insertSort(li,num): for i in range(1,num): j = i while li[j] < li[j-1] and j > 0 : tmp = li[j] li[j] = li[j-1] li[j-1] = tmp j -=1 for k in range(len(li)): if k != len(li)-1: print(li[k],"",end="") else: print(li[k]) if __name__ == '__main__': num = int(input()) li = list(map(in...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,372
s005601998
p02255
u319394183
1575381940
Python
Python3
py
Accepted
20
5600
407
def InsertSort(A, N): str_A = map(str, A) print(" ".join(str_A)) for i in range(N - 1): for j in range(i + 1): if A[i + 1 - j] < A[i - j]: A[i + 1 - j], A[i - j] = A[i - j], A[i + 1 - j] else: pass str_A = map(str, A) print(' '...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,373
s077632820
p02255
u014618861
1575352139
Python
Python3
py
Accepted
40
6312
378
n = int(input()) a = list(map(int,input().split())) def allprint(a, n): for i in range(n): if i > 0: print(" ",end="") print(a[i],end="") print("") def insertionSort(a, n): for i in range(1,n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j + 1] = a[j] j -= 1 a[j + 1...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,374
s222072016
p02255
u123367247
1575348730
Python
Python3
py
Accepted
20
5608
257
N = int(input()) A = [i for i in map(int, input().split())] print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,375
s060537416
p02255
u873403715
1575187282
Python
Python3
py
Accepted
20
5620
1,717
def ALDS1_1_A(): """ 1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A 2 for i が 1 から N-1 まで 3 v = A[i] 4 j = i - 1 5 while j >= 0 かつ A[j] > v 6 A[j+1] = A[j] 7 j-- 8 A[j+1] = v <問題> N 個の要素を含む数列 A を昇順に並び替える挿入ソートのプログラムを作成してください。 上の疑似コードに従いアルゴリズムを実...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,376
s851753933
p02255
u123563150
1575163736
Python
Python3
py
Accepted
20
5976
160
n=int(input()) a=list(map(int,input().split())) print(*a) for i in range(1,n): v=a[i] j=i-1 while j>=0 and a[j]>v: a[j+1]=a[j] j-=1 a[j+1]=v print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,377
s593680436
p02255
u862284621
1575137793
Python
Python3
py
Accepted
20
5604
380
def insertion_sort(a, n): print(' '.join(map(str, a))) for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j + 1] = a[j] j -= 1 a[j + 1] = v print(' '.join(map(str, a))) if __name__ == "__main__": n = int(input()) a = l...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,378
s516387680
p02255
u288628876
1575117936
Python
Python3
py
Accepted
20
5608
245
N, *A = map(int, open(0).read().split()) print(' '.join(list(map(str, A)))) for i in range(1, N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(list(map(str, A))))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,379
s921945271
p02255
u841945203
1575083113
Python
Python3
py
Accepted
30
5992
387
def output_A(A): if len(A) == 1: print(A[0]) else: for i in range(len(A)-1): print(f'{A[i]} ',end="") print(f'{A[i+1]}',) N = int(input()) A = list(map(int,input().split())) output_A(A) for i in range(1,len(A)): key = A[i] j = i-1 while j>=0 and A[j] > key : ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,380
s431225762
p02255
u916736774
1575028663
Python
Python3
py
Accepted
30
6076
997
import sys import math input = sys.stdin.readline def main(): sc = Scan() n = sc.intarr()[0] array = sc.intarr() for i in array: if i == array[-1]: print(i, end='') else: print(i, end=' ') print("") for i in range(1, n): v = array[i] j ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,381