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
s141577966
p02255
u357747289
1588772830
Python
Python3
py
Accepted
40
5976
479
n = int(input()) a_str = input().split() a = [int(i) for i in a_str] c = 1 for s in a: if c != n: print("{} ".format(s), end="") elif c == n: print(s) c += 1 i = 1 while n-1 >= i: v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,182
s428147989
p02255
u327396500
1588757930
Python
Python3
py
Accepted
20
5604
282
n = int(input()) A = list(map(int, input().split())) l = [str(a) for a 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(a) for a in A] print(" ".join(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,183
s212153751
p02255
u233634805
1588662407
Python
Python3
py
Accepted
20
5604
301
N = int(input()) A = list(map(int, input().split())) s = [str(a) for a in A] s = ' '.join(s) 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 = [str(a) for a in A] s = ' '.join(s) 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,184
s192668498
p02255
u114583562
1588577062
Python
Python3
py
Accepted
40
5976
186
n = int(input()) l = list(map(int,input().split())) for j in range(n): a = l[j] v = j-1 while v>=0 and l[v]>a: l[v+1]=l[v] l[v]=a v -=1 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,185
s118264515
p02255
u500034977
1588550952
Python
Python3
py
Accepted
30
6316
294
N = int(input()) A = list(map(int,input().split())) [print(A[x],'',end='') for x in range(N-1)] 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 [print(A[x],'',end='') for x in range(N-1)] 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,186
s396783131
p02255
u286298310
1588522162
Python
Python3
py
Accepted
20
5608
310
def insort(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 L=[str(a) for a in A] L=" ".join(L) print(L) n = int(input()) A = list(map(int,input().split())) insort(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,187
s528049843
p02255
u560578228
1588466824
Python
Python3
py
Accepted
20
5980
375
def insertion_sort(N, A): 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) def main(): N = int(input()) A = list(map(int, input().split())) insertion_sort...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,188
s939249774
p02255
u927832151
1588309920
Python
Python3
py
Accepted
20
5596
147
N = int(input()) aa = list(map(int, input().split())) for i in range(N): tmpl = sorted(aa[:i+1]) + aa[i+1:] print(" ".join(map(str,tmpl)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,189
s942704986
p02255
u211370436
1588245681
Python
Python3
py
Accepted
30
6276
443
# https://onlinejudge.u-aizu.ac.jp/problems/ALDS1_1_A import sys from functools import reduce def to_str(x, y): return str(x) + ' ' + str(y) input() A = list(map(int, input().split())) print(reduce(to_str, A)) for i in range(1, len(A)): v = A[i] j = i - 1 while j >= 0 and A[j] > v: 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,190
s289060189
p02255
u347281577
1588235779
Python
Python3
py
Accepted
20
5592
252
n = int(input()) L = list(map(int,input().split())) print(' '.join(map(str, L))) 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 print(' '.join(map(str,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,191
s083245524
p02255
u800829827
1588235318
Python
Python3
py
Accepted
20
5596
279
n = int(input()) #s = input() #print(s) a = list(map(int,input().split())) #print(a) print(' '.join(map(str,a))) for i in range(1, n): v = a[i] j = i - 1 while (j>=0 and a[j] > v): a[j+1] = a[j] j -= 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,192
s126765804
p02255
u065951775
1588165338
Python
Python3
py
Accepted
20
5600
295
def insertionSort(A, N): for i in range(N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j += -1 A[j+1] = v print(" ".join(map(str, A))) n = int(input()) A = list(map(int, input().split())) insertionSort(A, n)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,193
s049493835
p02255
u556600138
1588159166
Python
Python3
py
Accepted
20
5596
246
n = int(input()) A = list(map(int,input().split())) print(' '.join(map(str, A))) for i in range(1,n): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j = 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,194
s692952220
p02255
u042858714
1588081280
Python
Python3
py
Accepted
20
5976
198
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,195
s104412200
p02255
u514127623
1588077083
Python
Python3
py
Accepted
20
5604
341
def printArray(A): strA = [str(i) for i in A] print(" ".join(strA)) def insertion(A,N): for i in range(1,N): printArray(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 printArray(A) 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,196
s570581720
p02255
u374037476
1588074647
Python
Python3
py
Accepted
20
5596
200
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,197
s649373800
p02255
u527209617
1588065205
Python
Python3
py
Accepted
20
5600
381
n = int(input()) num_list = list(map(int, input().split())) def insertion_sort(lst): n = len(lst) for i in range(n): current = lst[i] j = i - 1 while j >= 0 and lst[j] > current: lst[j + 1] = lst[j] j -= 1 lst[j + 1] = current map_lst = map(str, 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,198
s773475552
p02255
u945415253
1588056596
Python
Python3
py
Accepted
40
5984
563
num = int(input()) sort_list = list(map(int,input().split())) for i in range(1,num): for n, sl in enumerate(sort_list): if n != num - 1: print('{} '.format(sl),end='') else: print('{}'.format(sl)) tmp = sort_list[i] j = i -1 while j >= 0 and sort_list[j] >= tmp:...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,199
s424178020
p02255
u600934585
1588054062
Python
Python3
py
Accepted
20
5976
194
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,200
s116528066
p02255
u720405234
1588052792
Python
Python3
py
Accepted
20
5976
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,201
s573510257
p02255
u572207441
1588007073
Python
Python3
py
Accepted
20
5980
223
n = int(input()) l = [] l = input().split() l = list(map(int,l)) print(*l) 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 = j - 1 l[j+1] = v print(*l)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,202
s102539092
p02255
u164933847
1587970905
Python
Python3
py
Accepted
20
5608
507
def insertSort(input_list): print(' '.join([str(i) for i in input_list])) for i in range(1, len(input_list)): tmp = input_list[i] j = i - 1 while j >= 0 and input_list[j] > tmp: input_list[j + 1] = input_list[j] j -= 1 input_list[j + 1] = tmp ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,203
s070749868
p02255
u175707104
1587918200
Python
Python3
py
Accepted
20
5608
232
N = int(input()) A = list(map(int, input().split())) for i in range(N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join([str(n) for n 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,204
s216386385
p02255
u771123742
1587878456
Python
Python3
py
Accepted
20
5600
252
N = int(input()) A = list(map(int, input().split())) for i in range(1, N): print(" ".join(map(str, A))) for j in range(i-1, -1, -1): if A[j] < A[j+1]: break A[j], A[j+1] = A[j+1], A[j] 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,205
s255944258
p02255
u575572987
1587864010
Python
Python3
py
Accepted
20
5980
450
def InsertionSort(A, N): for i in range(N): v = A[i] # A[i]は未ソート部分の先頭 j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] # vよりも大きい要素を一つ右に移動させる j -= 1 # 比較する位置を移動 A[j+1] = v # 空いた部分にvを入れる print(*A) N = int(input()) A = list(map(int, inp...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,206
s875653960
p02255
u421290920
1587708813
Python
Python3
py
Accepted
20
5984
212
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,207
s170418991
p02255
u758426656
1587705739
Python
Python3
py
Accepted
20
5604
396
N = int(input()) list_cards = [0]*N list_cards = list(map(int,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 A_str = list(map(str, A)) print(" ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,208
s409330693
p02255
u720435112
1587636499
Python
Python3
py
Accepted
20
5604
349
def insertion_sort(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 A[j+1] = v print(' '.join(map(str, A))) return A n = int(input()) A = list(map(int, input().split())) 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,209
s970404046
p02255
u219141430
1587632836
Python
Python3
py
Accepted
20
5976
270
# Indertion Sort n = int(input()) A = list(map(int, input().split())) def insertSort(A): print(*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 A[j + 1] = v print(*A) return 0 insertSort(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,210
s762446517
p02255
u748843150
1587619309
Python
Python3
py
Accepted
30
5976
377
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...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,211
s125037497
p02255
u486183171
1587602481
Python
Python3
py
Accepted
20
5976
216
N = int(input()) A = [int(a) for a in input().split()] print(*A) for i in range(1, N): v = A[i] j = i - 1 while 0 <= j and v < A[j]: A[j + 1] = A[j] j -= 1 A[j + 1] = v 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,212
s270954468
p02255
u107504501
1587526705
Python
Python3
py
Accepted
20
5984
302
N=int(input()) R=list(map(int,input().split())) print(*R) for n in range(1,N): if R[n-1]<=R[n]: pass elif R[n-1]>R[n]: v=R[n] for i in R[:n]: if i>v: j=R.index(i) break R[j+1:n+1]=R[j:n] R[j]=v print(*R)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,213
s284336131
p02255
u353604693
1587482117
Python
Python3
py
Accepted
20
5980
188
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,214
s565729488
p02255
u664556998
1587454421
Python
Python3
py
Accepted
30
5996
421
def printData(data): for d in data: val = f'{d}' if data[-1] != d: end = " " else: end = "\n" print(f'{d}',end=end) num = int(input()) data = list(map(int,input().split())) printData(data) for i in range(1,num): v = data[i] j = i -1 while 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,215
s121986691
p02255
u353888999
1587443685
Python
Python3
py
Accepted
20
5980
224
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,216
s450927301
p02255
u636645824
1587404938
Python
Python3
py
Accepted
20
5980
235
n = int(input()) arr = list(map(int, input().split())) print(*arr) for i in range(1, n): key = arr[i] j = i - 1 while j >= 0 and arr[j] > key: arr[j + 1] = arr[j] j -= 1 arr[j + 1] = key 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,217
s701043624
p02255
u411092946
1587378545
Python
Python3
py
Accepted
20
5984
196
n = int(input()) a = list(map(int, input().split())) print(*a) for i in range(1, n): v = a[i] while i-1 >= 0 and a[i-1]>v: a[i]=a[i-1] i -= 1 a[i] = 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,218
s647622182
p02255
u586336597
1587369793
Python
Python3
py
Accepted
20
5604
331
n=int(input()) #li1=list(map(int,input().split())) #li=[int(x) for x in input.split()] li=[int(x) for x in input().split()] #print(li1,li2) 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 l=[str(a) for a in li] l=" ".join(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,219
s334766722
p02255
u450536093
1587302176
Python
Python3
py
Accepted
20
5604
308
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)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,220
s609013244
p02255
u006326793
1587294937
Python
Python3
py
Accepted
30
5984
351
n = int(input()) A = list(map(int, input().split())) def trace(): for i in range(len(A)): if i != len(A) - 1: print(A[i],end=' ') else: print(A[i]) 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 -=...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,221
s276531281
p02255
u354055348
1587180967
Python
Python3
py
Accepted
30
5984
319
n = int(input()) a = list(map(int,input().split())) 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 for k in range(n): if k != n-1: print(a[k], end=' ') else: print(a[k], end='') print()
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,222
s498464124
p02255
u561994208
1587128339
Python
Python3
py
Accepted
20
5604
383
def insertSort(a,n): L=[str(ai) for ai in a] L=" ".join(L) print(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(ai) for ai in a] L=" ".join(L) print(L) n = 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,223
s349997884
p02255
u609694002
1586966070
Python
Python3
py
Accepted
20
5976
218
n = int(input()) A = list(map(int, input().split(' '))) print(*A) for i in range(1, n): t = A[i] k = i - 1 while k >= 0 and t < A[k]: A[k + 1] = A[k] k -= 1 A[k + 1] = t 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,224
s846175555
p02255
u240091169
1586914574
Python
Python3
py
Accepted
30
5980
355
def insertionSort(A, N) : for i in range(N) : v = A[i] j = i - 1 while j >= 0 and A[j] > v : A[j+1] = A[j] j -= 1 A[j+1] = v for j in range(N-1) : print(A[j], end=" ") print(A[N-1]) 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,225
s356014398
p02255
u837597523
1586867446
Python
Python3
py
Accepted
20
5608
273
n = int(input()) a = list(map(int, input().split())) print(' '.join([str(x) for x in a])) for i in range(1, n): v = a[i] j = i - 1 while (j >= 0) and (a[j] > v): a[j+1] = a[j] j -= 1 a[j+1] = v print(' '.join([str(x) for x in a]))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,226
s243573601
p02255
u474356387
1586820790
Python
Python3
py
Accepted
20
5604
278
N = input() l = [int(i) for i in input().split()] mapped_l = map(str, l) print(" ".join(mapped_l)) for i in range(1, len(l)): key = l[i] j = i-1 while j >= 0 and l[j] > key: l[j+1] = l[j] j -= 1 l[j+1] = key mapped_l = " ".join(map(str, l)) print(mapped_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,227
s267261860
p02255
u476858890
1586797411
Python
Python3
py
Accepted
30
5984
395
from sys import stdin input = stdin.readline N = int(input()) A = list(map(int, input().split())) def p(N): for i in range(len(N)): if i == len(N) - 1: print(N[i]) else: print(N[i], end=" ") p(A) for i in range(1, N): s = A[i] j = i - 1 while j >= 0 and 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,228
s793745378
p02255
u220937000
1586784651
Python
Python3
py
Accepted
20
5600
263
N=int(input()) lst=list(map(int,input().split())) print(' '.join(map(str,lst))) for i in range(1,len(lst)): j = i-1 ele = lst[i] while j>=0 and lst[j] > ele: lst[j+1] = lst[j] j-=1 lst[j+1] = ele print(' '.join(map(str,lst)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,229
s786360794
p02255
u669113302
1586773410
Python
Python3
py
Accepted
20
5604
219
n = int(input()) A = [int(_) for _ 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(' '.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,230
s557402665
p02255
u811841526
1586668220
Python
Python3
py
Accepted
20
5600
278
def print_list(l): print(' '.join(map(str, l))) n = int(input()) l = list(map(int, input().split())) print_list(l) 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 print_list(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,231
s491132448
p02255
u525049397
1586634240
Python
Python3
py
Accepted
20
5980
191
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,232
s171592946
p02255
u590535211
1586598154
Python
Python3
py
Accepted
20
5984
261
N=int(input()) A=list(map(int,input().split())) for i in range(N): j=i-1 insertion_A=A[i] while j >= 0: if A[j] > insertion_A: A[j+1] = A[j] else: break j -= 1 A[j+1]=insertion_A print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,233
s379392118
p02255
u208167569
1586584538
Python
Python3
py
Accepted
20
5980
225
n = int(input()) *lst, = map(int, input().split()) for i in range(1, n): print(*lst) v = lst[i] j = i - 1 while j>=0 and lst[j]>v: lst[j+1] = lst[j] j -= 1 lst[j+1] = v print(*lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,234
s175976328
p02255
u021005365
1586514789
Python
Python3
py
Accepted
20
5604
255
N = int(input()) As = [int(x) for x in input().split()] print(" ".join(map(str,As))) for i in range(1,N): v = As[i] j = i - 1 while j >= 0 and As[j] > v: As[j+1] = As[j] j -= 1 As[j+1] = v print(" ".join(map(str,As)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,235
s225621520
p02255
u745322345
1586489431
Python
Python3
py
Accepted
20
5608
562
#!/usr/local/bin python # -*- coding: utf-8 -*- # # ~/aizu/alds11a_insertionSort.py # def insertionSort(a: list, n: int): a_string_list = map(str, a) output = ' '.join(a_string_list) print(output) for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: 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,236
s399830253
p02255
u384243329
1586479284
Python
Python3
py
Accepted
20
5608
241
# -*- coding:utf8 -*- n = int(input()) l = list(map(int, input().split())) for i in range(n): v = l[i] j = i - 1 while j >= 0 and l[j] > v: l[j+1] = l[j] l[j] = v j -= 1 print(' '.join(map(str, 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,237
s551049103
p02255
u282759714
1586466318
Python
Python3
py
Accepted
20
5608
370
# 挿入ソート N = int(input()) A = list(map(int, input().split())) def insertionSort(A, N): print(' '.join([str(i) for i in A])) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j+1] = v print(' '.join([str(...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,238
s496072964
p02255
u546267901
1586401167
Python
Python3
py
Accepted
20
5616
390
n = int(input()) A = list(map(int,input().split())) print(' '.join(map(str, A))) ''' for i in range(n): print(A[i], end=' ') 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 i in range(n): 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,239
s745186975
p02255
u713172874
1586341483
Python
Python3
py
Accepted
30
5984
469
def insertionSort(A): 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 for i in range(len(A)): if i == len(A)-1: print(A[i],end="\n") else: 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,240
s593187643
p02255
u716254110
1586337257
Python
Python3
py
Accepted
30
5976
459
n = input() A = list(map(int, input().split())) for index in range(len(A)): if index != len(A) - 1: print(A[index], end=" ") else: print(A[index]) for i in range(1, len(A)): key = A[i] j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j -= 1 A[j+1] = key f...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,241
s988993829
p02255
u142111310
1586259895
Python
Python3
py
Accepted
20
5980
310
def insertion_sort(lst): for i in range(1, len(lst)): v = lst[i] j = i - 1 while j >= 0 and lst[j] > v: lst[j+1] = lst[j] j -= 1 lst[j+1] = v print(*lst) n = int(input()) lst = list(map(int, input().split())) print(*lst) insertion_sort(lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,242
s456163902
p02255
u027759050
1586256474
Python
Python3
py
Accepted
30
5992
566
n = int(input()) #A = [int(input()) for i in range(n)] L = [int(i) for i in input().split()] def InsertionSort(A,N): 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 item in range(len(A)): if item == len(A)-1: print(A[item]) else: ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,243
s374750377
p02255
u672903396
1586092617
Python
Python3
py
Accepted
20
5600
235
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,244
s642532140
p02255
u507639574
1585883939
Python
Python3
py
Accepted
20
5980
310
def insert_sort(A, N): print(*A, sep=' ') for i in range(1, N): tmp = A[i] j = i-1 while j>=0 and A[j]>tmp: A[j+1] = A[j] j -= 1 A[j+1] = tmp print(*A, sep=' ') N = int(input()) A = list(map(int, input().split())) insert_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,245
s264754540
p02255
u157179698
1585754339
Python
Python3
py
Accepted
20
5596
281
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,246
s412703165
p02255
u772508436
1585710996
Python
Python3
py
Accepted
20
5596
395
n = int(input()) original_list = list(map(int,input().split())) maped_list = map(str, original_list) print(' '.join(maped_list)) for i in range(1,n): v = original_list[i] j = i - 1 while j >= 0 and original_list[j] > v: original_list[j+1] = original_list[j] j = j - 1 original_list[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,247
s206723556
p02255
u081312678
1585710713
Python
Python3
py
Accepted
30
5980
293
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 k in range(len(A)): if k != len(A)-1: print(A[k],end=' ') else: print(A[k])
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,248
s013449820
p02255
u220079276
1585539028
Python
Python3
py
Accepted
20
5976
214
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,249
s765662463
p02255
u587528376
1585457153
Python
Python3
py
Accepted
20
5592
261
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 v<A[j]):#<で安定になる 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,250
s143597784
p02255
u798363880
1585402714
Python
Python3
py
Accepted
30
5984
333
N=int(input()) A=list(map(int,input().split())) # A = [int(i) for i in input().split()] # for i in range(N):print(A[i],end='') # print(end='\n') for i in range(N): v=A[i] j=i-1 while(j>=0 and A[j]>v): A[j+1]=A[j] j-=1 A[j+1]=v for i in range(N):print(A[i],end=' \n'[i+1==N]) # pri...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,251
s712630754
p02255
u940492895
1585348480
Python
Python3
py
Accepted
30
6312
333
N = int(input()) A = [int(i) for i in input().split()] def printA(): for i in range(0, N-1): print(A[i], '', end='') print(A[N-1]) for i in range(0,N): v = A[i] for j in range(i,-1,-1): if A[j-1] <= v or j == 0: A[j+1:i+1] = A[j:i] A[j] = v break ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,252
s935472078
p02255
u838900850
1585211510
Python
Python3
py
Accepted
20
5604
302
def main(): 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))) if __name__ == '__main__': 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,253
s768194920
p02255
u349218688
1585164678
Python
Python3
py
Accepted
20
5592
247
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 v < A[j] and j >= 0: 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,254
s090937206
p02255
u976757712
1585134445
Python
Python3
py
Accepted
20
5976
173
N = int(input()) A = list(map(int, input().split())) for i in range(N): p = i -1 while p >= 0 and A[p] > A[p+1]: A[p], A[p+1] = A[p+1], A[p] p -= 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,255
s406912697
p02255
u737337423
1585030207
Python
Python3
py
Accepted
20
5980
222
N, *A = map(int, open(0).read().split()) print(*A) for i, a in enumerate(A): if i == 0: continue j = i-1 while j >= 0 and A[j]>a: A[j], A[j+1] = a, A[j] 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,256
s370304614
p02255
u440695009
1584942571
Python
Python3
py
Accepted
20
5976
203
n=int(input()) table=list(map(int,input().split())) def insertsort(a,n): for i in range(n): v=a[i] j=i-1 while j>=0 and a[j]>v: a[j+1]=a[j] j-=1 a[j+1]=v print(*a) insertsort(table,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,257
s073023976
p02255
u618350292
1584931833
Python
Python3
py
Accepted
20
5612
350
#! /usr/bin/env python3 # -*- coding: utf-8 -*- import sys N = int(input()) A = [int(x) for x in input().split()] if len(A) != N: print("[ERROR] Number of Input integer is invalid") sys.exit() 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 ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,258
s974417968
p02255
u258049727
1584874426
Python
Python3
py
Accepted
20
5604
244
n = int(input()) a = [int(i) for i in input().split()] print(" ".join(map(str,a))) for i in range(1,n): v = a[i] j = i-1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(" ".join(map(str,a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,259
s789376508
p02255
u957585260
1584722429
Python
Python3
py
Accepted
30
5984
382
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...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,260
s280115686
p02255
u397697633
1584717309
Python
Python3
py
Accepted
20
5832
5,049
import itertools def spaced_to_ints(spaced_some): return [int(a) for a in spaced_some.split(" ")] def order_sequence_chars(str): return list(str) def get_dice(): input_data = input().split(" ") items = [int(cont) for cont in input_data] keys = ['T', 'S', 'E', 'W', 'N', 'B'] return dict(zip(ke...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,261
s509425780
p02255
u985742483
1584577484
Python
Python3
py
Accepted
20
5592
251
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,262
s762827753
p02255
u512832033
1584418697
Python
Python3
py
Accepted
20
5604
366
# ALDS1_1_A: Insertion Sort 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 = j - 1 A[j+1] = v 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,263
s877164558
p02255
u835794786
1584201430
Python
Python3
py
Accepted
20
5604
347
def insertion_sort(A, N): for i in range(1, N): v = A[i] j = i - 1 print(' '.join(list(map(str, A)))) while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join(list(map(str, A)))) N = int(input()) A = list(map(int, input().spli...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,264
s929541456
p02255
u176870835
1584096715
Python
Python3
py
Accepted
20
5592
233
n = int(input()) a = list(map(int,input().split())) for i in range(n): j = i-1 key = a[i] #print(key) while 0 <= j and key < a[j]: 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,265
s830908617
p02255
u954858867
1584062751
Python
Python
py
Accepted
10
4648
249
N = int(raw_input()) A = list(map(int,raw_input().split())) print ' '.join([str(a) for a in A]) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j-=1 A[j+1] = v print ' '.join([str(a) for a in A])
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,266
s702866818
p02255
u240839092
1584038012
Python
Python3
py
Accepted
20
5980
201
N = int(input()) A = list(map(int, input().split())) for i in range(N): key = A[i] j = i - 1 while A[j] > key and j >=0: A[j+1] = A[j] j -= 1 A[j+1] = key print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,267
s357195369
p02255
u119355204
1583837210
Python
Python3
py
Accepted
20
5596
239
N=int(input()) L=list(map(int,input().split())) print(' '.join(map(str,L))) for i in range(1,N): for j in range(i): if L[i] < L[j]: v=L.pop(i) L.insert(j,v) print(' '.join(map(str,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,268
s778070877
p02255
u921038488
1583666757
Python
Python3
py
Accepted
30
5976
487
def show(nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else: print(nums[i]) def intersetion_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 -= 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,269
s193681585
p02255
u129526553
1583659601
Python
Python3
py
Accepted
50
7168
536
from typing import MutableSequence def insertion_sort(A_list: MutableSequence, num: int) -> None: """挿入ソート""" for i in range(num): j = i tmp = A_list[i] while j > 0 and A_list[j - 1] > tmp: A_list[j] = A_list[j - 1] j -= 1 A_list[j] = tmp prin...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,270
s156325216
p02255
u773687908
1583645867
Python
Python3
py
Accepted
20
5600
291
def print_list(num_list): print(" ".join(map(str, num_list))) N = int(input()) A = list(map(int, input().split())) print_list(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_list(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,271
s728960262
p02255
u350924040
1583477280
Python
Python3
py
Accepted
20
5980
296
n = int(input()) l = list(map(int, input().split())) print(*l) 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) insertionsort(l, n)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,272
s732884606
p02255
u773266448
1583454570
Python
Python3
py
Accepted
20
5600
299
n = int(input()) a = list(map(int,input().split())) print(" ".join(map(str,a))) def insertsort(m,b): j = 1 while j <= m - 1: for t in range(0,j): if b[t] > b[j]: b[t],b[j] = b[j],b[t] j += 1 print(" ".join(map(str,b))) insertsort(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,273
s760743654
p02255
u415118689
1583421537
Python
Python3
py
Accepted
20
5976
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,274
s148962260
p02255
u859384502
1583409703
Python
Python3
py
Accepted
20
5976
342
def insertionSort(self,len): for i in range(1,len,1): print(*self) v = self[i] #2 j = i - 1 while j >= 0 and self[j] > v: self[j+1] = self[j] j-=1 self[j+1] = v print(*self) numslen = int(input()) nums = [int(e) for e in input().split()] insert...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,275
s917552100
p02255
u641702731
1583372262
Python
Python3
py
Accepted
20
5976
285
def main(): input() ary = list(map(int,input().split())) print(*ary) for i in range(1, len(ary)): v = ary[i] j = i - 1 while (j >= 0) and (ary[j] > v): ary[j + 1] = ary[j] j -= 1 ary[j + 1] = v print(*ary) if __name__ == '__main__': 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,276
s000842784
p02255
u577505488
1583258033
Python
Python3
py
Accepted
20
5604
330
def main(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))) return A if __name__ == "__main__": N = int(input()) A = list(map(int, input().split())) ma...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,277
s085458479
p02255
u112247126
1583241992
Python
Python3
py
Accepted
20
5984
296
N = int(input()) li = list(map(int, input().split())) # N = 6 # li = [5, 2, 4, 6, 1, 3] for i in range(1, N): print(*li) v = li[i] for j in reversed(range(0, i)): if li[j] > v: li[j + 1] = li[j] li[j] = v else: break print(*li)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
31,278
s122382975
p02255
u581890166
1583163483
Python
Python3
py
Accepted
20
5980
209
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,279
s861810448
p02255
u012110006
1583151786
Python
Python3
py
Accepted
20
5596
193
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,280
s816360849
p02255
u328186352
1583150594
Python
Python3
py
Accepted
20
5976
229
def insertSort(n, a): for i in range(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(*a) insertSort(int(input()), [int(i) for i in 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,281