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
s263079235
p02255
u794140916
1574936837
Python
Python3
py
Accepted
30
5984
585
# coding: utf-8 # Your code here! def insertionSort(A, N): for i in range(1, N): #print("sorting") 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-...
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,382
s854983499
p02255
u705234550
1574753570
Python
Python3
py
Accepted
20
5596
254
N = int(input()) A = list(map(int, input().split())) print(" ".join(map(str, A))) for i in range(1,N): v = A[i] for j in range(i): if A[i-j-1]>v: A[i-j] = A[i-j-1] A[i-j-1] = v else: break 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,383
s049706332
p02255
u798961710
1574700473
Python
Python3
py
Accepted
20
5600
327
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))) n = int(input()) a = list(map(int, input().split())) print(" ".join(map(str, 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,384
s327988682
p02255
u001204484
1574434975
Python
Python3
py
Accepted
20
5980
263
N = int(input()) A = list(map(int, input().split(' '))) print(*A) for i in range(1, N): V = A[i] insert_index = i for j in reversed(range(i)): if A[j] > V: insert_index = j A.pop(i) A.insert(insert_index, 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,385
s387936164
p02255
u379137542
1574410831
Python
Python3
py
Accepted
20
5984
212
n=int(input()) A=[int(i) for i in input().split()] for i in range(n): v =A[i] j=i-1 while (j>=0)&(A[j]>v): #print('i=', i) #print('j=',j) 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,386
s632351955
p02255
u088330375
1574310759
Python
Python3
py
Accepted
20
5604
333
n = int(input()) array = list(map(int, input().split())) print(' '.join([str(e) for e in array])) for i in range(1, len(array)): inserting = array[i] j = i - 1 while j >= 0 and array[j] > inserting: array[j+1] = array[j] j -= 1 array[j+1] = inserting print(' '.join([str(ele) for ele ...
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,387
s272021639
p02255
u821608651
1574310353
Python
Python3
py
Accepted
30
5988
419
import sys sys.setrecursionlimit(10 ** 6) int1 = lambda x: int(x) - 1 p2D = lambda x: print(*x, sep="\n") def main(): n = int(input()) aa = list(map(int, input().split())) for i in range(n): a = aa.pop(i) for j in range(i - 1, -1, -1): if aa[j] <= a: aa.insert(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,388
s760928035
p02255
u081389879
1574093290
Python
Python
py
Accepted
10
4656
497
def main(): n = int(raw_input().strip()) data = map(int, raw_input().split()) print " ".join([str(x) for x in data]) insertion_sort(n, data) def insertion_sort(n, data): for i in xrange(1, n): if data[i - 1] > data[i]: temp = data[i] while i > 0 and data[i - 1] > tem...
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,389
s847908445
p02255
u234489316
1573813666
Python
Python3
py
Accepted
20
5984
215
N = int(input()) IN = list(map(int,input().split())) print(*IN) for i in range(1,N): v = IN[i] j = i - 1 while j >= 0 and IN[j] > v: IN[j+1] = IN[j] j -= 1 IN[j+1] = v print(*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,390
s259083970
p02255
u430736685
1573782452
Python
Python3
py
Accepted
20
5600
279
N = int(input()) A = list(map(int, input().split())) def insertionSort(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(map(str, A))) insertionSort(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,391
s146223105
p02255
u942508230
1573654819
Python
Python3
py
Accepted
20
5976
305
N = int(input()) A = list(map(int, input().split())) def insertionSort(A, N): for i in range(1, 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 print(*A) print(*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,392
s738467582
p02255
u342549725
1573576243
Python
Python3
py
Accepted
20
5600
349
n = int(input()) l = list(map(int,input().split())) def insertionSort(l,n): ans = map(str,l) print(" ".join(ans)) for i in range(1,n): v = l[i] j = i - 1 while j>=0 and l[j]>v: l[j+1]=l[j] j -= 1 l[j+1] = v ans = map(str,l) print(" ".jo...
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,393
s497653264
p02255
u707745674
1573529129
Python
Python3
py
Accepted
20
5976
223
N = int(input()) A = [int(i) for i in 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,394
s253169715
p02255
u529459816
1573456708
Python
Python3
py
Accepted
20
5604
538
def insertion_sort(array, num): print(" ".join(map(str, array))) for i in range(1, num): right_val = array[i] j = i - 1 while j >= 0 and array[j] > right_val: array[j + 1] = array[j] j = j - 1 array[j + 1] = right_val print(" ".join(map(str, array)...
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,395
s298649794
p02255
u079552231
1573390777
Python
Python3
py
Accepted
20
5600
483
N = int(input()) numbers = list(map(int,input().split())) def trace(numbers): a = str(numbers[0]) for i in range(1,len(numbers)): a += " " a += str(numbers[i]) print(a) trace(numbers) for current_i in range(1,N): for compare_i in range(current_i-1,-1,-1): if(numbers[compare_i] > numbers[current_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,396
s381119162
p02255
u793120772
1572774713
Python
Python3
py
Accepted
20
5976
217
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,397
s262238794
p02255
u877347085
1572763954
Python
Python3
py
Accepted
20
5980
297
N = int(input()) A = list(map(int,input().split())) def insertion_sort(A): print(*A) for j in range(1,len(A)): key=A[j] i=j-1 while i>=0 and A[i]>key: A[i+1]=A[i] i=i-1 A[i+1]=key print(*A) return A insertion_sort(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,398
s227638575
p02255
u221724886
1572655218
Python
Python3
py
Accepted
20
5980
353
# -*- coding: utf-8 -*- # ALDS1_1_A: Insertion Sort def insertion_sort(a, n): for i in range(1, n): print(*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) n = int(input()) a = list(map(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,399
s577053647
p02255
u297517978
1572526889
Python
Python3
py
Accepted
20
5980
263
n=int(input()) l=list(map(int, input().split())) for i in range(n): if i!=n: part_l=sorted(l[0:i+1]) l=part_l+l[i+1:n+1] print(*l) elif i==n: if l[i-1]>l[i]: l=+list(reversed(l[i-1:i])) 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,400
s924744418
p02255
u780342333
1572310729
Python
Python3
py
Accepted
20
5976
428
#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 >= 0 and A[j] > key # A[j+1] = A[j] # j-- # A[j+1] = key n = int(input()) nums = list(map(int, input().split())) for i in range(0, n): key = nums[i] j = i - 1 while ...
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,401
s859308201
p02255
u608189632
1572270980
Python
Python3
py
Accepted
20
5596
387
N = int(input()) A = list(map(int, input().split())) # A_sort = A A_str = map(str, A) print(" ".join(A_str)) for i in range(1, N, 1): # for j in range(i): # if A[i] < A_sort[j]: # A_sort[j+1] = 1 v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] 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,402
s384212903
p02255
u505428702
1572247997
Python
Python3
py
Accepted
20
5976
169
n = int(input()) a = [int(i) for i 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 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,403
s261853905
p02255
u383095076
1572245565
Python
Python3
py
Accepted
20
5608
266
L, A = int(input()), input() print(A) A = [int(i) for i in A.split()] for i in range(1, L): 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(k) for k in A] l = ' '.join(l) 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,404
s808042149
p02255
u700487145
1572216075
Python
Python3
py
Accepted
20
5608
295
N = int(input()) A = [int(x) for x in input().split()] A_str = [str(a) for a in A] print(" ".join(A_str)) for i in range(1, N): j = i-1 while A[i] < A[j] and j >=0: A[j], A[i] = A[i], A[j] j -= 1 i -= 1 A_str = [str(a) for a 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,405
s742485214
p02255
u639364872
1572139142
Python
Python3
py
Accepted
30
5980
210
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] j -= 1 A[j+1] = v 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,406
s043360365
p02255
u958870136
1572097104
Python
Python3
py
Accepted
30
5976
362
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,407
s378640011
p02255
u160342618
1572072424
Python
Python3
py
Accepted
20
5596
249
N=int(input()) A=list(map(int,input().split())) B=list(map(str,A)) print(' '.join(B)) for i in range(1,N): v=A[i] j=i-1 while j!=-1 and A[j]>v: A[j+1]=A[j] j-=1 A[j+1]=v B=list(map(str,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,408
s523130673
p02255
u732073438
1572060931
Python
Python3
py
Accepted
30
5976
254
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 for j in range(len(A)-1): print(A[j],end=" ") print(A[-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,409
s009247603
p02255
u829695570
1572057504
Python
Python3
py
Accepted
20
5596
245
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,410
s332673072
p02255
u504636463
1572014418
Python
Python3
py
Accepted
30
5980
562
def print_list(numlist): n = len(numlist) for i in range(n): if i == n - 1: print(numlist[i]) else: print(numlist[i], end=' ') if __name__ == '__main__': n = int(input()) numlist = [int(num) for num in input().split(' ')] print_list(numlist) ...
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,411
s449224628
p02255
u417951787
1571924032
Python
Python3
py
Accepted
30
5976
365
n = int(input()) list1 = list(map(int,input().split())) for i in range(0,n): v = list1[i] for j in range(i,-1,-1): if list1[j] > v: tmp = list1[j] list1[j] = v list1[j+1] = tmp for m in range(n): if m == n-1: print(list1[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,412
s046226235
p02255
u724234786
1571638124
Python
Python3
py
Accepted
30
6296
635
import functools def pretty_print(arr: [int]): return functools.reduce(lambda a, b: f'{a} {b}', arr) def custom_sort(arr: [int]): print(pretty_print(arr)) for i in range(1, len(arr)): val = arr[i] # print(f'val is {val}') j = i - 1 # print(j >= 0, arr[j] > val) w...
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,413
s464938414
p02255
u851070389
1571523289
Python
Python3
py
Accepted
20
5608
283
import sys n = int(input()) a = list(map(int, input().split())) for i in range(1, n): print(' '.join(list(map(str, 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(' '.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,414
s778219331
p02255
u057125975
1571455454
Python
Python3
py
Accepted
30
5980
490
def print_arr(arr): for i in range(len(arr)): if i != len(arr) - 1: print(arr[i], end=' ') else: print(arr[i], end='') print() if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) print_arr(arr) for i in range(1, len(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,415
s087871326
p02255
u613320068
1571209415
Python
Python3
py
Accepted
20
5596
223
n = int(input()) ls = list(map(str, input().split())) for i in range(n): v = ls[i] j = i - 1 while j >= 0 and int(ls[j]) > int(v): ls[j+1] = ls[j] j -= 1 ls[j+1] = v print(' '.join(ls))
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,416
s116110525
p02255
u121563294
1571158772
Python
Python3
py
Accepted
20
5596
198
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,417
s817171359
p02255
u976944239
1571115939
Python
Python3
py
Accepted
30
5984
542
#挿入ソート def print_output(_list): for index in range(len(_list)): if index == len(_list) - 1: print(_list[index]) else: print(_list[index],end=' ') target_length = int(input()) target_list = list(map(int,input().split())) print_output(target_list) for index in range(1, target_...
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,418
s006864209
p02255
u244026635
1571060612
Python
Python3
py
Accepted
20
5984
285
n = int(input()) a = list(map(int, input().split())) 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) print(*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,419
s570957434
p02255
u907647136
1571041648
Python
Python3
py
Accepted
20
5608
244
n = int(input()) a = [int(i) for i in input().split()] for i in range(1,n): print(' '.join(map(str,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(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,420
s658099463
p02255
u578043650
1570979122
Python
Python3
py
Accepted
20
5604
320
num = int(input()) arr = list(map(int,input().split())) print(" ".join(list(map(str,arr)))) def isn(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(list(map(str,arr)))) isn(arr,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,421
s619217318
p02255
u894062759
1570849955
Python
Python3
py
Accepted
20
5976
510
n = int(input()) a = list(map(int, input().split())) print(*a) for i in range(len(a)-1): #print(' '.join([str(i) for i in a])) l = i j = l + 1 while l >= 0: #print(l, j) #print(*a) # val1 = a[i] # val2 = a[j] #if val2 < val1: if a[j] < 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,422
s050847749
p02255
u814680900
1570729536
Python
Python3
py
Accepted
20
5980
307
import sys input = sys.stdin.readline N=int(input()) A = list(map(int, input().split())) def insertionSort(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) print(*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,423
s375628808
p02255
u177078820
1570641318
Python
Python3
py
Accepted
20
5984
252
n=int(input()) l=[int(x) for x in input().split()] for i in range(n): j=i while j>0 : if l[j-1]>l[j]: a=l[j] l[j]=l[j-1] l[j-1]=a j-=1 else : break 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,424
s642961284
p02255
u410881919
1570533274
Python
Python3
py
Accepted
20
5604
316
def func(n, A): for i in range(1, n): print (" ".join(map(str, 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(map(str, A))) n = int(input()) A = list(map(int, input().split(" "))) func(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,425
s326302354
p02255
u174500606
1570522708
Python
Python3
py
Accepted
30
5976
254
N=int(input()) A=[] A=input().split() A=[int(u) for u in A] 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=j-1 A[j+1]=v for u in range(0,N-1): print(A[u],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,426
s198520929
p02255
u481641204
1570343912
Python
Python3
py
Accepted
20
5600
364
#17D8101028I tou koutetsu 2019/10/3 #ID:tanghaozhe #python n=int(input()) X=list(map(int,input().split())) curX=[] for index,i in enumerate(X): curX.append(i) for j in range(index,0,-1): # print(curX,"j=",j) if j>0 and curX[j]<curX[j-1]: tmp=curX[j-1] curX[j-1]=curX[j] curX[j]=tmp res=curX+X[index+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,427
s792742315
p02255
u656765249
1570291435
Python
Python3
py
Accepted
20
5600
275
# -*- coding: utf-8 -*- n = int(input()) a = list(map(int, input().split())) for i in range(1, n): print(" ".join(map(str, a))) v = a[i] j = i - 1 while (j >= 0) & (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,428
s093483087
p02255
u476418873
1570163368
Python
Python3
py
Accepted
20
5596
334
n = int(input()) NUM_STR = input() print(NUM_STR) NUM_LIST = list(map(int, NUM_STR.split())) for i in range(1, len(NUM_LIST)): v = NUM_LIST[i] j = i - 1 while NUM_LIST[j] > v and j >= 0: NUM_LIST[j+1] =NUM_LIST[j] j -= 1 NUM_LIST[j+1] = v STR = list(map(str, NUM_LIST)) 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,429
s829995052
p02255
u500444410
1570099951
Python
Python3
py
Accepted
20
5980
256
N=int(input()) A=[int(i)for i in input().split()] 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) 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,430
s450832417
p02255
u778781355
1570095455
Python
Python3
py
Accepted
20
5980
283
def insertionSort(A, N): print(*A) for i in range(1, N): value = A[i] j = i - 1 while j >= 0 and A[j] > value: A[j + 1] = A[j] j -= 1 A[j + 1] = value print(*A) if __name__ == "__main__": 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,431
s193479512
p02255
u447421429
1570075222
Python
Python3
py
Accepted
20
5980
254
n=int(input()) a=list(map(int,input().split())) def InsertionSort(a,n): for i in range(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(*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,432
s319717154
p02255
u367690536
1570073802
Python
Python3
py
Accepted
30
5976
314
N=int(input()) a=list(map(int,input().split())) #print(a) 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=j-1 a[j+1]=v for k in range(N-1): print(a[k],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,433
s464551044
p02255
u386372137
1570072886
Python
Python3
py
Accepted
30
5976
314
N=int(input()) A=list(map(int,input().split())) for i in range(1,N): v = A[i] j = i - 1 for k in range(N-1): print(A[k], end=" ") print(A[N-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-1): print(A[j], 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,434
s562637556
p02255
u405373749
1570072558
Python
Python3
py
Accepted
20
5596
214
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,435
s864294448
p02255
u994057612
1570072227
Python
Python3
py
Accepted
30
5980
324
x=int(input()) a=list(map(int,input().split())) for k in range(x-1): print(a[k],end=' ') print(a[x-1]) for i in range(1,x): j=i-1 b=a[i] while j >= 0 and a[j] > b: a[j+1]=a[j] j=j-1 a[j+1]=b for k in range(x-1): print(a[k],end=' ') print(a[x-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,436
s496329336
p02255
u238519222
1570071824
Python
Python3
py
Accepted
20
5976
216
N = int(input()) A = [int(x) for x in 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,437
s341383610
p02255
u271489440
1570071433
Python
Python3
py
Accepted
20
5984
182
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,438
s056684190
p02255
u658163678
1570071396
Python
Python3
py
Accepted
20
5976
241
N = int(input()) list = [int(x) for x in input().split()] print(*list) for i in range(1, N): v = list[i] j = i - 1 while j >= 0 and list[j] > v: list[j+1] = list[j] j = j - 1 list[j+1] = v print(*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,439
s972039597
p02255
u767055917
1570071091
Python
Python3
py
Accepted
30
5980
352
n = int(input()) List = [int(i) for i in input().split()] for i in range(1,n): for k in range(n-1): print(List[k], end=" ") print(List[n-1]) j = i-1 v = List[i] while j >= 0 and List[j] > v: List[j+1] = List[j] j-=1 List[j+1] = v for k in range(n-1): print(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,440
s221802479
p02255
u261940473
1570069973
Python
Python3
py
Accepted
20
5600
225
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,441
s531391576
p02255
u657462090
1570069690
Python
Python3
py
Accepted
20
5980
271
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 print(*A) N=int(input()) A=list(map(int,input().split())) print(*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,442
s291985427
p02255
u529561768
1570069654
Python
Python3
py
Accepted
20
5980
299
def insertion_sort(Array,num): for i in range(1,num): v=Array[i] j=i-1 while(j>=0 and Array[j]>v): Array[j+1]=Array[j] j-=1 Array[j+1]=v print(*A) n=int(input()) A=[int(i) for i in input().split()] print(*A) 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,443
s166523540
p02255
u169491531
1570069097
Python
Python3
py
Accepted
20
5984
263
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] j=j-1 A[j+1]=v print(*A,sep=" ") 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,444
s919485716
p02255
u236088139
1570068815
Python
Python3
py
Accepted
20
5596
257
n = int(input()) a = list(map(int, input().split())) for i in range(1, n): print(' '.join(map(str, 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(' '.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,445
s039643001
p02255
u537758214
1570068171
Python
Python3
py
Accepted
20
5984
426
def main(): def insertSort(A): N = len(A) for i in range(1,N): print(*A) val = A[i] j = i - 1 while j >= 0 and A[j] > val: A[j+1] = A[j] j -= 1 A[j+1] = val else: print(*A) N = int(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,446
s303565308
p02255
u800816961
1570011929
Python
Python3
py
Accepted
20
5608
630
def insertion_sort(array): n = len(array) for i in range(1, n): tmp = array[i] # 挿入する値を退避 if tmp < array[i-1]: # 挿入する位置までずらしていく j = i while True: array[j] = array[j-1] j -= 1 if j == 0 or tmp >= 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,447
s347681610
p02255
u083019081
1569998642
Python
Python3
py
Accepted
20
5596
225
n=int(input()) a=list(map(int,input().split())) for i in range(1,n): print(" ".join(map(str,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(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,448
s624895334
p02255
u655267413
1569923168
Python
Python3
py
Accepted
20
5980
273
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()) A = list(map(int,input().split())) print(*A) 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,449
s870560172
p02255
u852592538
1569853639
Python
Python3
py
Accepted
20
5600
251
n = int(input()) nums = list(map(int, input().split())) print(" ".join(list(map(str, nums)))) for i in range(1, n): for j in range(i): if nums[j] > nums[i]: nums.insert(j, nums.pop(i)) print(" ".join(list(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,450
s004822939
p02255
u128808587
1569767808
Python
Python3
py
Accepted
20
5980
292
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()) A = list(map(int, input().split())) print(*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,451
s693515481
p02255
u776329965
1569664051
Python
Python3
py
Accepted
30
5984
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 else: A[j + 1] = v for b in range(n): print(A[b], end=" \n"[b + 1 == 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,452
s806131033
p02255
u216986815
1569640364
Python
Python3
py
Accepted
20
5600
445
def insert_sort(nums, n): for i in range(1, n): nums_str = map(str, nums) print(" ".join(nums_str)) v = nums[i] j = i - 1 while j >= 0 and nums[j] > v: nums[j+1] = nums[j] j-=1 nums[j+1] = v nums_str = map(str, nums) print(" ".join(nu...
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,453
s172844034
p02255
u169229232
1569417719
Python
Python3
py
Accepted
20
5976
296
N = int(input()) A = list(map(int, input().split())) def insertionSort(li: list, n: int): for i in range(n): v = li[i] j = i - 1 while 0 <= j and v < li[j]: li[j+1] = li[j] j -= 1 li[j+1] = v print(*li) 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,454
s571576436
p02255
u637097953
1569321569
Python
Python3
py
Accepted
20
5596
231
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,455
s386801378
p02255
u448439399
1569267041
Python
Python3
py
Accepted
20
5604
222
N = int(input()) S = list(map(int, input().strip().split())) for i in range(1, N+1): tmp = S[:i] tmp.sort() sroted_list = tmp + S[i:] str_list =[str(j) for j in sroted_list] print(' '.join(str_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,456
s075133782
p02255
u459733576
1569219141
Python
Python3
py
Accepted
20
5608
440
import sys input = sys.stdin.readline def main(): N = int(input()) P = list(map(int, input().split())) print(' '.join(map(str, P))) insertionSort(N, P) def insertionSort(N, P): for i in range(1, N): v = P[i] j = i - 1 while j >= 0 and P[j] > v: P[j + 1] = P[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,457
s195256185
p02255
u333299212
1569184077
Python
Python3
py
Accepted
20
5612
282
n=int(input()) a=[int(i) for i in input().split()] #print(" ".join(list(map(str,a)))) for i in range(n): x=a[i] for j in range(i): if a[i-j-1]>a[i-j]: a[i-j-1],a[i-j]=a[i-j],a[i-j-1] else: break 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,458
s634200332
p02255
u439083584
1569174134
Python
Python3
py
Accepted
20
5976
187
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 v<A[j]: 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,459
s566201397
p02255
u950982677
1569150945
Python
Python3
py
Accepted
20
5604
306
n=int(input()) A = list(map(int,input().split())) sA=[str(i) for i in A] pA = ' '.join(sA) print(pA) 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) sA=[str(i) for i in A] pA = ' '.join(sA) print(pA)
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,460
s455735771
p02255
u257219057
1569147406
Python
Python3
py
Accepted
20
5612
443
def insertion_sort(arr, num): for i in range(1, num): 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(c) for c in a])) if __name__ == '__main__': n = int(input()) a_str: str = 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,461
s543922802
p02255
u586920078
1568963741
Python
Python3
py
Accepted
30
5980
338
N = int(input()) A = [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 _ in range(N): if _ == N-1: print(A[_],sep='',end='') else: print(A[_], sep='',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,462
s564661665
p02255
u979148405
1568824629
Python
Python3
py
Accepted
20
5984
89
n,*a=map(int,open(0).read().split()) for i in range(1,n+1):a[:i]=sorted(a[:i]);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,463
s187235736
p02255
u180322859
1568738213
Python
Python3
py
Accepted
20
5600
250
from sys import stdin n = int(stdin.readline().rstrip()) li = list(map(int,stdin.readline().rstrip().split())) li2 = [] for i in range(len(li)): s = li.pop(0) li2.append(s) li2.sort() ans = li2+li print(' '.join(map(str, ans)))
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,464
s785903130
p02255
u815450098
1568634752
Python
Python3
py
Accepted
20
5600
243
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,465
s468588657
p02255
u899624451
1568565918
Python
Python3
py
Accepted
30
5956
408
N = int(input()) A = [int(x) for x in input().split()] for k in range(N): if k == N - 1: print(A[k]) else: print(A[k], end=" ") 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): ...
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,466
s865075376
p02255
u689084681
1568450216
Python
Python3
py
Accepted
20
5600
284
N=int(input()) A=list(map(int,input().split())) A_str=map(str,A) string=" ".join(A_str) print(string) 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=map(str,A) string=" ".join(A_str) print(string)
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,467
s797931563
p02255
u641623772
1568447875
Python
Python3
py
Accepted
30
5592
210
N = int(input()) A = list(map(int, input().split())) for i, a in enumerate(A): j = i - 1 while j >= 0 and A[j] > a: A[j+1] = A[j] j -= 1 A[j+1] = a 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,468
s413937792
p02255
u839269354
1568432747
Python
Python3
py
Accepted
20
5608
478
def insertion_sort(a, n): # N個の要素を含む0-オリジンの配列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 output(a) return a def main(): n = int(input()) a = [int(x) for x in input().split()] 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,469
s301926214
p02255
u444032915
1568275809
Python
Python3
py
Accepted
20
5600
203
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(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,470
s195786161
p02255
u244359727
1568265404
Python
Python3
py
Accepted
20
5976
195
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,471
s814006112
p02255
u366363301
1568220428
Python
Python3
py
Accepted
30
5988
356
#coding: utf-8 n = int(input()) a = list(map(int, input().split())) def view(): print(str(a[0]), end = '') for k in range(1, n): print(' {}'.format(a[k]), end = '') print('') for i in range(1, n): view() v = a[i] j = i - 1 while j >= 0 and a[j] > v: 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,472
s159091742
p02255
u526189710
1568175010
Python
Python3
py
Accepted
40
6320
510
N = int(input()) s = list(map(int, input().split())) for k in range(N): if k>0: print(" ",sep='',end='') print(s[k],sep='',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=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,473
s167169153
p02255
u314932236
1568040451
Python
Python3
py
Accepted
20
5604
218
def main(n): 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))) return main(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,474
s740697186
p02255
u650018120
1568034209
Python
Python3
py
Accepted
20
5604
454
def insertionSort(A, N): print(' '.join([str(i) for i in A])) for i in range(1, N): # print(' '.join([str(i) for i 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(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,475
s344415339
p02255
u811733736
1568032724
Python
Python3
py
Accepted
20
5980
289
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 print(*A) N = int(input()) A = list(map(int, input().split())) print(*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,476
s394893594
p02255
u647694976
1568017266
Python
Python3
py
Accepted
20
5984
245
n=int(input()) box=list(map(int,input().split())) print(*box) for i in range(1,n): while 1: if i==0:break elif box[i]<box[i-1]: box[i],box[i-1]=box[i-1],box[i] i -=1 else:break print(*box)
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,477
s114559459
p02255
u991321321
1568002361
Python
Python3
py
Accepted
20
5608
284
# 1_1_A_InsertionSort.py n = int(input()) a = [int(x) for x in input().split()] print(' '.join([str(x) for x in a])) for i in range(1, len(a)): for j in range(i, 0, -1): if a[j] < a[j-1]: a[j], a[j-1] = a[j-1], a[j] 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,478
s113874510
p02255
u003984259
1567950367
Python
Python3
py
Accepted
30
5976
308
def show(A): for i in range(N): if i<N-1: print(A[i],end=' ') else: print(A[i]) 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,479
s556441846
p02255
u813197825
1567942989
Python
Python3
py
Accepted
20
5604
318
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: if a[j] > v: a[j + 1], a[j] = a[j], a[j - 1] j -= 1 else: break 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,480
s514725978
p02255
u134521115
1567942052
Python
Python3
py
Accepted
20
5600
265
N = int(input()) A = list(map(int, input().split())) for i in range(1, N): print(' '.join(list(map(str, 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(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,481