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
s539998407
p02255
u322457988
1567734802
Python
Python3
py
Accepted
30
5976
286
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) f = 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,482
s287506624
p02255
u367619546
1567686624
Python
Python3
py
Accepted
40
6320
366
def trace(X): for i in range(len(X)): print(X[i], end='') if i != len(X) - 1: print(' ', end='') print('') N = int(input()) A = [int(i) for i in input().split()] for i in range(1, N): trace(A) v = A[i] j = i - 1 while (j >= 0) and (A[j] > v): A[j + 1] = 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,483
s396884742
p02255
u399509886
1567662597
Python
Python3
py
Accepted
40
6284
474
def print_result(A, n): for i in range(n): if i > 0: print(' ', end='') print(A[i], end='') print('\n', end='') def insertion_sort(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 ...
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,484
s765439774
p02255
u629170852
1567596185
Python
Python3
py
Accepted
20
5596
222
i=int(input()) n=list(map(int,input().split())) print(' '.join(map(str, n))) for k in range(1,i): target=n[k] hh=k-1 while hh>=0 and n[hh]>target: n[hh+1]=n[hh] hh-=1 n[hh+1]=target print(' '.join(map(str, 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,485
s212595843
p02255
u651566573
1567512547
Python
Python3
py
Accepted
40
6320
440
def prList(A): n = len(A) for i in range(n): if i: print(" ", end="") print(A[i], end="") print("") def insertSort(A): n = len(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 ...
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,486
s029094133
p02255
u910017046
1567455381
Python
Python3
py
Accepted
20
5984
328
# ALDS1_1_A - Insertion Sort def main(): N, *A = map(int, open(0).read().split()) print(*A) for i in range(1, 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(*A) if __name__ == "__main__": ...
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,487
s030506550
p02255
u661205028
1567414000
Python
Python3
py
Accepted
20
5980
246
if __name__ == '__main__': N = int(input()) A = list(map(int, input().split())) print(*A) for i in range(1, N): while(i >= 1 and A[i-1] > A[i]): A[i], A[i-1] = A[i-1], A[i] i -= 1 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,488
s424236660
p02255
u405726708
1567261096
Python
Python3
py
Accepted
20
5980
202
n = int(input()) a = list(map(int, input().split())) b = [] for i in range(n): k = a[i] j = i - 1 while j >= 0 and a[j] > k: a[j+1] = a[j] a[j]=k j-=1 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,489
s602512248
p02255
u603762757
1567153678
Python
Python3
py
Accepted
30
5980
279
N = int(input()) A = list(map(int, input().split())) def printa(A): for i in range(N - 1): print(A[i] ,end=' ') print(A[N - 1],) printa(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 printa(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,490
s415588845
p02255
u846497769
1566834800
Python
Python3
py
Accepted
20
5604
256
N = int(input()) A =list(map(int,input().split())) L = [str(a) for a in A] B = " ".join(L) print(B) 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 L = [str(a) for a in A] B = " ".join(L) print(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,491
s378647807
p02255
u803862921
1566828037
Python
Python3
py
Accepted
40
6316
365
num = int(input()) a = [int(x) for x in input().split()] def plist(a): for i in range(len(a)): print(a[i],end="") if i < len(a)-1: print(" ",end="") print() plist(a) for i in range(1,num): tmp = a[i] j = i - 1 while (j >= 0 and a[j] > tmp): 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,492
s236140064
p02255
u773296755
1566790105
Python
Python3
py
Accepted
20
5608
341
def insertion_sort(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))) n = int(input()) test = list(map(int,input().split())) print(' '.join(map(str,test))) ins...
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,493
s322072444
p02255
u452254067
1566744475
Python
Python3
py
Accepted
30
5980
363
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[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,494
s151526892
p02255
u344890307
1566696569
Python
Python3
py
Accepted
20
5596
219
N=int(input()) nums=list(map(int,input().split())) for i in range(0,N): key = nums[i] j= i-1 while j >= 0 and nums[j] > key: nums[j+1] = nums[j] j = j-1 nums[j+1] = key print(" ".join(map(str,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,495
s834440097
p02255
u945201912
1566653888
Python
Python3
py
Accepted
30
5992
375
def test(): n = int(input()) A = list(map(int,input().split())) for k in range(n-1): print(f"{A[k]} ",end = '') print(f"{A[n-1]}") for i in range(1,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 for k in range(n-1): print(f"{A[k]} ",end = '') 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,496
s888736093
p02255
u784856415
1566440111
Python
Python3
py
Accepted
20
5984
193
n=int(input()) a=list(map(int,input().split())) print(*a) for i in range(1,n): num=a[i] j=i-1 while j>=0 and a[j]>num: a[j+1]=a[j] j-=1 a[j+1]=num 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,497
s404157221
p02255
u225805609
1566266427
Python
Python3
py
Accepted
20
5596
228
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=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,498
s995467356
p02255
u749355444
1566110644
Python
Python
py
Accepted
10
4636
119
N = input() A = map(int, raw_input().split()) for i in range(N): print " ".join(map(str, sorted(A[:i+1])+A[i+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,499
s774289594
p02255
u092830990
1566088774
Python
Python3
py
Accepted
30
5988
384
def display(l): for item in l: if not item == l[-1]: print(f"{item}", end=' ') else: print(item) n = int(input()) lst = list(map(int, input().split())) display(lst) for i in range(1, len(lst)): key = lst[i] j = i - 1 while j >= 0 and lst[j] > key: lst[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,500
s885893822
p02255
u017438068
1566031093
Python
Python3
py
Accepted
20
5980
294
def insertion_sort(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()) m = list(map(int, input().split())) print(*m) insertion_sort(m,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,501
s657195721
p02255
u511006108
1565964694
Python
Python3
py
Accepted
20
5984
378
#! /usr/bin/python # -*- coding: utf-8 -*- n=int(input()) # 数列の長さ A=list(map(int, input().split())) # 空白を区切文字として配列に格納 print(*A) for i in range(1, n): key = A[i] # insert A[i] into the sorted sequence A[0,...,j-1] j = i - 1 while j >= 0 and A[j] > key: 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,502
s786448855
p02255
u639928232
1565756230
Python
Python3
py
Accepted
20
5592
187
n=int(input()) A=input().split() print(' '.join(A)) for i in range(1,n): key=int(A[i]) j=i-1 while j>=0 and int(A[j])>key: A[j+1]=A[j] j-=1 A[j+1]=str(key) 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,503
s135343752
p02255
u921810101
1565724929
Python
Python3
py
Accepted
20
5608
455
def FUNC00(ARG00): for VAR00 in range(1, len(ARG00)): VAR01 = ARG00[VAR00] VAR02 = VAR00 - 1 while VAR02 >= 0 and ARG00[VAR02] > VAR01: ARG00[VAR02 + 1] = ARG00[VAR02] VAR02 -= 1 ARG00[VAR02 + 1] = VAR01 print(' '.join([str(VAR03) for VAR03 in ARG00]))...
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,504
s620073586
p02255
u608789460
1565710493
Python
Python3
py
Accepted
20
5980
193
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 -= 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,505
s352100560
p02255
u206091536
1565701334
Python
Python3
py
Accepted
20
5608
249
N=int(input()) A=list(map(int,input().split())) for i in range(len(A)): val=A[i] j=i-1 while (j>=0 and A[j]>val): A[j+1]=A[j] j=j-1 A[j+1]=val string=[str(a) for a in A] out=' '.join(string) print(out)
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,506
s149867062
p02255
u048191691
1565598894
Python
Python3
py
Accepted
20
5596
269
N = int(input()) A = list(map(int,input().split())) for i in range(N-1): print (" ".join(map(str,A))) i += 1 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,507
s192295375
p02255
u815830103
1565559169
Python
Python3
py
Accepted
40
6316
435
N = int(input()) A = [int(x) for x in input().split()] def pr(A): N = len(A) for i in range(N): if i != 0: print(" ",end = "") print(A[i], end = "") print("") def insertionSort(A): N =len(A) for i in range(1,N): v = A[i] j = i - 1 while j >= 0 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,508
s381690019
p02255
u175224634
1565507181
Python
Python3
py
Accepted
30
5984
274
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 = j-1 A[j+1] = v for k in range(n-1): print(str(A[k]) + " ", end = "") print(str(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,509
s583282421
p02255
u143588661
1565433745
Python
Python3
py
Accepted
20
5596
247
r = int(input()) A = list(map(int, input().split())) print(" ".join(map(str, A))) for i in range(1, r): j = i - 1 v = A[i] 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,510
s597537736
p02255
u131318999
1565427809
Python
Python3
py
Accepted
20
5604
460
#insertion sort def printout(array,n): output = "" for i in range(n-1): output += str(array[i]) + " " output += str(array[N-1]) print(output) N = int(input()) array = [int(i) for i in input().split()] printout(array,N) for i in range(1,N): a = array[i] for j in reversed(range(0,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,511
s020849896
p02255
u030816022
1565330168
Python
Python3
py
Accepted
20
5604
332
valuenum = int(input()) Input = input() print(Input) values = [int(value) for value in Input.split()] for i in range(1,valuenum): for j in range(0,i): if values[i] < values[j]: values.insert(j, values[i]) values.pop(i + 1) break ans = map(lambda value:str(value), values) print(' '.join(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,512
s424446111
p02255
u216229195
1565231956
Python
Python3
py
Accepted
20
5612
316
def insertion_sort(a, n): for i in range(n): v = a[i] j = i-1 while((j>=0)&(v<a[j])): a[j+1] = a[j] j -= 1 a[j+1] = v print(" ".join([str(i) for i in a])) return 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,513
s505930927
p02255
u972439298
1565128541
Python
Python3
py
Accepted
20
5604
618
def InsertionSort(data): show(data) for i in range(1, len(data)): temp = data[i] for j in reversed(range(0, i)): if data[j] > temp: data[j+1] = data[j] else: data[j+1] = temp break if j == 0: dat...
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,514
s671826370
p02255
u623270342
1565107758
Python
Python3
py
Accepted
20
5976
176
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,515
s644933761
p02255
u750428486
1565066521
Python
Python3
py
Accepted
40
5988
435
num = int(input()) num_list = input().split(" ") nums = [] for n in num_list: nums.append(int(n)) for m in range(num): i = nums[m] j = m - 1 while j >= 0 and nums[j] > i: nums[j+1] = nums[j] j -= 1 nums[j+1] = i for n in range(num): if n == len(nums)-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,516
s484764625
p02255
u778810039
1565012731
Python
Python3
py
Accepted
20
5604
332
def main(): n = int(input()) al = list(map(int, input().split(' '))) for i in range(n): v = al[i] j = i - 1 while j >= 0 and al[j] > v: al[j + 1] = al[j] j -= 1 al[j + 1] = v print(' '.join(list(map(str, al)))) if __name__ == '__main__':...
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,517
s110759881
p02255
u499561491
1564927373
Python
Python3
py
Accepted
20
5976
390
def insertion_sort(A): for i in range(1,len(A)): print(*A) key = A[i] #/* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j-=1 A[j+1] = key if __name__=='__main__': n=int(input()) ...
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,518
s103028602
p02255
u218784088
1564919544
Python
Python3
py
Accepted
20
5596
244
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,519
s729927256
p02255
u543882621
1564917284
Python
Python3
py
Accepted
20
5596
368
num_inputs = int(input()) input_array = input().split(' ') for i in range(1, num_inputs): print(' '.join(input_array)) current_value = input_array[i] j = i - 1 while j >= 0 and int(input_array[j]) > int(current_value): input_array[j + 1] = input_array[j] j -= 1 input_array[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,520
s510661740
p02255
u924938296
1564843001
Python
Python3
py
Accepted
30
5976
363
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[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,521
s848435676
p02255
u910413188
1564810667
Python
Python3
py
Accepted
20
5608
288
n=int(input()) A=list(map(int,input().split())) def convert(list): s=[str(i) for i in list] res = " ".join(s) return res print(convert(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(convert(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,522
s893535440
p02255
u470586273
1564806649
Python
Python3
py
Accepted
20
5596
196
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,523
s537072353
p02255
u467711590
1564761567
Python
Python3
py
Accepted
30
5976
363
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[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,524
s053390144
p02255
u964325672
1564653175
Python
Python3
py
Accepted
20
5612
312
n = int(input()) A = list(map(int,input().split(" "))) def fun(n,A): 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(["{0["+ str(i) + "]}" for i in range(n)]).format(A)) fun(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,525
s649149555
p02255
u214526598
1564633698
Python
Python3
py
Accepted
30
5976
370
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[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,526
s871447160
p02255
u974159247
1564399157
Python
Python3
py
Accepted
20
5596
283
n = int(input()) nums = list(map(int, input().split())) print(' '.join(map(str, nums))) for i in range(1, n): key = nums[i] j = i - 1 while j >= 0 and nums[j] > key: nums[j + 1] = nums[j] j -= 1 nums[j + 1] = key print(' '.join(map(str, 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,527
s916994021
p02255
u520885582
1564299455
Python
Python3
py
Accepted
20
5980
219
n = int(input()) A = [int(s) for s in input().split()] print(*A) for i in range(1, n): key = A[i] j = i - 1 while j >= 0 and A[j] > key: j -= 1 A.insert(j+1, key) del A[i+1] 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,528
s644493852
p02255
u586792237
1564145119
Python
Python3
py
Accepted
20
5596
244
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,529
s392160220
p02255
u284857616
1564063461
Python
Python3
py
Accepted
20
5600
233
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], A[j+1] = A[j+1], A[j] j -= 1 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,530
s237305296
p02255
u816538599
1564042341
Python
Python3
py
Accepted
30
5984
370
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[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,531
s356612212
p02255
u088630381
1564041947
Python
Python3
py
Accepted
20
5604
263
def sort(a, n): print(" ".join(map(str, 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 print(" ".join(map(str, a))) N = int(input()) A = list(map(int, input().split())) 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,532
s491654452
p02255
u212392281
1564037597
Python
Python3
py
Accepted
40
6312
386
n = int(input()) a = list(map(int, input().split())) for j in range(n): print(a[j], end="") if j < n-1: print(" ", end="") else: print("") 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(n): 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,533
s913492354
p02255
u447488214
1563950534
Python
Python3
py
Accepted
20
5976
230
n = int(input()) a = list(map(int, input().split())) print(*a, sep=' ') for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] a[j] = v j -= 1 print(*a, sep=' ')
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,534
s492647324
p02255
u529337794
1563759229
Python
Python3
py
Accepted
20
5980
192
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 -= 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,535
s729372437
p02255
u271607594
1563613536
Python
Python3
py
Accepted
20
5600
498
def insertitionSort(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 = j -1 A[j+1] = v map_result = map(str, A) print(' '.join(map_result)) ### 出力形式を変換 ##from IPython.core.debugger 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,536
s279641523
p02255
u496021498
1563450444
Python
Python3
py
Accepted
20
5600
370
def insertionSort(A, N): for i in range(1, N): print(' '.join(map(lambda x: str(x), 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 return A N = int(input()) A = list(map(int, input().split())) A = insertionSort(...
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,537
s882995577
p02255
u150401016
1563366549
Python
Python3
py
Accepted
20
5596
319
N=int(input()) number=list(map(int,input().split())) print(' '.join(map(str,number))) for i in range(1,N): strage=number[i] j=i-1 for j in range(0,i)[::-1]: if number[j]>strage: number[j+1]=number[j] j-=1 number[j+1]=strage print(' '.join(map(str,number)))
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,538
s627741665
p02255
u853741520
1563324574
Python
Python3
py
Accepted
20
5608
396
n = int(input()) alist = list(map(int, input().split())) print(" ".join([str(i) for i in alist])) def insertion_sort(alist, n): for i in range(1, n): current = alist[i] j = i - 1 while j >= 0 and alist[j] > current: alist[j], alist[j+1] = alist[j+1], alist[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,539
s504923812
p02255
u623985331
1563294222
Python
Python3
py
Accepted
20
5976
174
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,540
s287549589
p02255
u527989889
1563219032
Python
Python3
py
Accepted
40
6320
566
num = int(input()) num_array = input().split(" ") for i in range(num): num_array[i] = int(num_array[i]) def put_array(): for i in range(num): print(num_array[i], end="") if i != num-1: print(" ", end="") else: print("") def insertionSort(A, N): for i in ra...
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,541
s634220503
p02255
u654661069
1563168945
Python
Python3
py
Accepted
20
5604
259
N = int(input()) A = list(map(int, input().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,542
s846125096
p02255
u790728164
1563030396
Python
Python3
py
Accepted
20
5604
394
N = int(input()) A = input().split() A = [int(i) for i in A] #listの要素を出力 def print_list_val(A): s = '' for i in range(len(A)): s = s + str(A[i]) if i != len(A) - 1: s += " " print(s) for i in range(N): 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,543
s967653481
p02255
u206854284
1563030140
Python
Python3
py
Accepted
20
5604
390
def insertionSort(A, N): for i in range(N): s = "" 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()) #1行目のNを取得する M = 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,544
s455538368
p02255
u314166831
1562952104
Python
Python3
py
Accepted
40
6408
2,784
# coding=utf-8 ### ### for atcorder program ### import sys import math # math class class mymath: ### pi pi = 3.14159265358979323846264338 ### Prime Number def pnum_eratosthenes(self, n): ptable = [0 for i in range(n+1)] plist = [] for i in range(2, n+1): if ptab...
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,545
s199867882
p02255
u861615356
1562884834
Python
Python3
py
Accepted
20
5612
345
N = int(input()) A = list(map(int, input().split())) def insertionSort(A, N): for i in range(N-1): print(' '.join(repr(e) for e in A)) v = A[i+1] j = i while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(repr(e) for e 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,546
s971033395
p02255
u811400777
1562738950
Python
Python3
py
Accepted
20
5600
276
def show(A): L = list(map(str, A)) print(" ".join(L)) N = int(input()) A = list(map(int, input().split())) 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 -= 1 A[j+1] = v show(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,547
s260974999
p02255
u615361919
1562691101
Python
Python3
py
Accepted
20
5604
325
if __name__=='__main__': N = int(input()) A = [ int(_) for _ in input().split(' ') ] print(' '.join(map(str,A))) for i in range(1, 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,...
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,548
s577654881
p02255
u817810878
1562679861
Python
Python3
py
Accepted
20
5608
457
if __name__ == "__main__": elem_num = int(input()) elems = list(map(lambda x: int(x), input().split())) print(" ".join([str(elem) for elem in elems])) # Initial state. for i in range(1, elem_num): key = elems[i] j = i - 1 while j >= 0 and elems[j] > key: elems[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,549
s409878015
p02255
u131148681
1562662130
Python
Python3
py
Accepted
20
5604
322
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] = A[j], A[j+1] j -= 1 print(' '.join(map(str, A))) N = int(input()) A = list(map(int, input().split())) print(' '.join(map(str, 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,550
s712148908
p02255
u487330611
1562564139
Python
Python3
py
Accepted
20
5980
390
def insertion_sort(A): for i in range(1,len(A)): print(*A) key = A[i] #/* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j-=1 A[j+1] = key if __name__=='__main__': n=int(input()) ...
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,551
s594393175
p02255
u455877373
1562561996
Python
Python3
py
Accepted
20
5604
259
N = int(input()) A = list(map(int, input().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,552
s438223481
p02255
u137240270
1562477029
Python
Python3
py
Accepted
20
5604
424
def main(): n = int(input()) array = [int(i) for i in input().split(' ')] my_print(array) for i in range(1, n): target = array[i] j = i - 1 while target < array[j] and j >= 0: array[j+1] = array[j] j -= 1 array[j+1] = target my_print(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,553
s076606324
p02255
u684891023
1562236357
Python
Python3
py
Accepted
20
5604
374
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))) if __name__ == "__main__": n = int(input()) a = list(map(int, input().split())) ...
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,554
s642463647
p02255
u534464795
1562072633
Python
Python3
py
Accepted
20
5596
174
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(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,555
s945154883
p02255
u734220756
1561999349
Python
Python3
py
Accepted
20
5608
421
# 插入排序 def insertion_sort(arr): for i in range(1, len(arr)): temp = arr[i] j = i - 1 while j >= 0 and arr[j] > temp: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = temp print(' '.join(map(str, arr))) if __name__ == '__main__': N = int(input()) 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,556
s324090536
p02255
u990900604
1561974339
Python
Python
py
Accepted
10
4644
353
if __name__ == '__main__': n = int(raw_input()) A = map(int, raw_input().split()) for x in A: print x, print 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 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,557
s385928622
p02255
u710943498
1561874194
Python
Python3
py
Accepted
20
5612
402
from sys import stdin N = int(stdin.readline().rstrip()) A = [int(_) for _ in stdin.readline().rstrip().split()] def insertion_sort(A, N): print(' '.join(str(_) for _ 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 ...
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,558
s932141609
p02255
u112577679
1561872599
Python
Python3
py
Accepted
20
5600
361
def insert_sort(n, nums): for i in range(1, n): key = nums[i] j = i - 1 while j >= 0 and nums[j] > key: nums[j+1] = nums[j] j -= 1 nums[j+1] = key print(' '.join(map(str, nums))) n = int(input()) nums = list(map(int, input().split())) print(' '.join...
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,559
s955701396
p02255
u602681368
1561782285
Python
Python3
py
Accepted
20
5596
262
n = int(input()) a = list(map(int, input().split())) s = " ".join(map(str, a)) print(s) 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 s = " ".join(map(str, a)) print(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,560
s908331966
p02255
u897625120
1561657918
Python
Python3
py
Accepted
20
5604
329
N = int(input()) A = [] nums = input().split() for i in range(N): A.append(int(nums[i])) l = [str(i) for i in A] print(" ".join(l)) 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 l = [str(i) for i in A] print(" ".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,561
s432091769
p02255
u315511072
1561640679
Python
Python3
py
Accepted
30
5984
347
def p(a): for i in a[:-1]: print(i,end=' ') print(a[-1]) def insertion_sort(a): for i in range(1,len(a)): p(a) d = a[i] j = i-1 while j>=0 and d<a[j]: a[j+1] = a[j] j = j-1 a[j+1] = d n = int(input()) l = list(map(int,input().split(...
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,562
s933121431
p02255
u230467383
1561559313
Python
Python3
py
Accepted
20
5600
329
def insertionSort(At, Nt): for i in range(Nt): v = At[i] j = i - 1 while j >= 0 and At[j] > v: A[j + 1] = A[j] j = j - 1 A[j + 1] = v print(" ".join(map(str,At))) return At if __name__ == '__main__': N = int(input()) A = list(map(int, input().split())) A = insertionSort(A, N) #print(" ".join(map(...
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,563
s859199102
p02255
u341188593
1561545124
Python
Python3
py
Accepted
20
5980
335
N = int(input()) A = list(map(int, input().split())) for k in range(N - 1): print(A[k], end = ' ') print(A[N - 1]) 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 for k in range(N - 1): print(A[k], end = ' ') 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,564
s018764012
p02255
u581420565
1561483004
Python
Python3
py
Accepted
20
5600
322
N = int(input()) A =list(map(int,input().split())) 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))) 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,565
s800826393
p02255
u051789695
1561299040
Python
Python3
py
Accepted
20
5980
193
n=int(input()) a=list(map(int,input().split())) print(*a) for i in range(1,n): num=a[i] j=i-1 while j>=0 and a[j]>num: a[j+1]=a[j] j-=1 a[j+1]=num 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,566
s108977915
p02255
u139489012
1561188098
Python
Python3
py
Accepted
40
6032
721
def insertion_sort(N,input_list): for i in range(1,N): for j in range(N): if j != N - 1: print(input_list[j],end=" ") else: print(input_list[j]) v = input_list[i] j = i - 1 while j>=0 and input_list[j] > v: input_lis...
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,567
s530455786
p02255
u875086819
1561102112
Python
Python3
py
Accepted
20
5980
194
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(*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,568
s442723019
p02255
u277375424
1560953008
Python
Python3
py
Accepted
20
5596
237
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,569
s169386777
p02255
u019713541
1560913004
Python
Python3
py
Accepted
20
5604
422
N = int(input()) As = list(map(int, input().split())) print(" ".join([str(a) for a in As])) for i in range(1,N): tmp = As[i] j = i - 1 # 上にさかのぼりながら挿入できるところを探す # さかのぼりきる & 今より大きいところが見つかる while j >= 0 and As[j] > tmp: As[j+1] = As[j] j -= 1 As[j+1] = tmp print(" ".join([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,570
s106211063
p02255
u638889288
1560860783
Python
Python3
py
Accepted
20
5600
1,072
N = int(input()) a = list(map(int, input().split())) print(" ".join(list(map(str, a)))) #「整列していない部分」から、順番に1つずつ取り出していく for i in range(1,len(a)): #「挿入する値」を、変数に取り出す tmp=a[i] #挿入する位置の変数を用意する ins=0 #「整列済みの部分」のどこに挿入すればいいのかを、後ろから前に向かって順番に見ていく for j in range(i-1,-1,-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,571
s874730997
p02255
u302205058
1560856359
Python
Python3
py
Accepted
20
5596
231
n = int(input()) li = list(map(int, input().split())) for i in range(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(str(li).replace(',', '')[1:-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,572
s383341019
p02255
u336705996
1560839465
Python
Python3
py
Accepted
20
5980
326
def insertionSort(n,a): for i in range(1,n): x = a[i] j = i print(*a) while j>0 and x < a[j-1]: a[j] = a[j-1] j -= 1 a[j] = x if __name__ == "__main__": n = int(input()) a = list(map(int, input().split())) insertionSort(n,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,573
s998446410
p02255
u471115210
1560682036
Python
Python3
py
Accepted
20
5632
300
N = int(input()) A_INPUT = list(map(int, input().split())) A = A_INPUT[:] import bisect for i in range(N): sorted_list = A[:i] v = A[i] unsorted_list = A[i+1:] bisect.insort(sorted_list, v) A = sorted_list + unsorted_list 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,574
s547300497
p02255
u500948606
1560674984
Python
Python3
py
Accepted
20
5980
318
n = int(input()) arr = list(map(int, input().split())) def insertionSort(arr, n): print(*arr) for i in range(1, 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(*arr) insertionSort(arr, 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,575
s576621277
p02255
u663301733
1560603410
Python
Python3
py
Accepted
20
5976
292
def insertion_sort(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] = A[j], A[j+1] j-=1 A[j+1] = v print(*A) n = int(input()) A = list(map(int, 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,576
s032566739
p02255
u662991395
1560580311
Python
Python3
py
Accepted
20
5600
261
n = int(input()) a = list(map(int,input().split())) print(' '.join(map(str,a))) for i in range(n-1): cur = sorted(a[:i+2]) if i != n-2: print(' '.join(map(str,cur))+' '+' '.join(map(str,a[i+2:]))) else: print(' '.join(map(str,cur)))
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,577
s693749057
p02255
u617401892
1560515669
Python
Python3
py
Accepted
20
5596
301
n = int(input()) a_list = list(map(int, input().split())) print(' '.join(map(str, a_list))) for i in range(1, n): key = a_list[i] j = i - 1 while j >= 0 and a_list[j] > key: a_list[j + 1] = a_list[j] j = j - 1 a_list[j + 1] = key print(' '.join(map(str, a_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,578
s685074892
p02255
u788553535
1560460451
Python
Python3
py
Accepted
20
5980
160
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(*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,579
s480916561
p02255
u571101772
1560329082
Python
Python3
py
Accepted
20
5608
362
def insertionSort(A, N): 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(' '.join([str(s) for s in A])) input_line = input() N = int(input_line) input_line = input() A = [int(s) for s in input_...
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,580
s378797951
p02255
u182175955
1560230480
Python
Python3
py
Accepted
30
5980
441
n=input() N=int(n) L=input().split() A=[int(L[i]) for i in range(N)] #for i in range(N):#入力をそのまま返す # if i<N-1: # print(A[i],end=" ") # else: # print(A[i]) 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 for k in range(...
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,581