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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s141033652 | p02255 | u604437890 | 1527138919 | Python | Python3 | py | Accepted | 30 | 5980 | 347 | def print_A():
for k, e in enumerate(A):
if k == N - 1:
print(e)
else:
print(e, end=' ')
N = int(input())
A = [int(n) for n 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
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,982 |
s867977875 | p02255 | u002280517 | 1527238161 | Python | Python3 | py | Accepted | 20 | 5596 | 250 | 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
| 30,983 |
s929570724 | p02255 | u684241248 | 1527418420 | Python | Python3 | py | Accepted | 30 | 5608 | 415 | N = int(input())
ary = [int(_) for _ in input().split()]
def insertion_sort(ary, verbose=True):
for i in range(1, N):
if verbose:
print(' '.join([str(_) for _ in ary]))
v = ary[i]
j = i - 1
while j >= 0 and ary[j] > v:
ary[j + 1] = ary[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
| 30,984 |
s187180163 | p02255 | u986478725 | 1527419547 | Python | Python3 | py | Accepted | 20 | 5596 | 765 | # ALDS_1_A.
def intinput():
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
return a
def show(a):
# 配列aの中身を出力する。
_str = ""
for i in range(len(a) - 1): _str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def main():
n = int(input())
a = intinput(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,985 |
s220710783 | p02255 | u986478725 | 1527419587 | Python | Python3 | py | Accepted | 20 | 5604 | 778 | # ALDS_1_A.
def intinput():
a = input().split()
for i in range(len(a)):
a[i] = int(a[i])
return a
def show(a):
# 配列aの中身を出力する。
_str = ""
for i in range(len(a) - 1): _str += str(a[i]) + " "
_str += str(a[len(a) - 1])
print(_str)
def main():
n = int(input())
a = intinput(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,986 |
s048205508 | p02255 | u007270338 | 1527484920 | Python | Python3 | py | Accepted | 20 | 5608 | 316 | #coding:utf-8
n = int(input())
A = list(map(int, input().split()))
B = " ".join([str(num) for num in A])
print(B)
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1], A[j] = A[j], A[j+1]
j -= 1
B = " ".join([str(num) for num in A])
print(B)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,987 |
s820141310 | p02255 | u604437890 | 1527504357 | Python | Python3 | py | Accepted | 30 | 5976 | 400 | def print_A():
for i, n in enumerate(A):
if i == N - 1:
print(n)
else:
print(n, end=' ')
def insert():
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
prin... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,988 |
s926523607 | p02255 | u318430977 | 1527524544 | Python | Python3 | py | Accepted | 30 | 5980 | 463 | 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_list_split_whitespace(a)
def print_list_split_whitespace(a):
for x in a[:-1]:
print(x, end=' ')
pr... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,989 |
s819050092 | p02255 | u991156486 | 1527600396 | Python | Python3 | py | Accepted | 30 | 5980 | 343 | n = int(input())
x = input().split()
y=[]
for i in range(n):
y += [int(x[i])]
for i in range(n-1):
print(y[i],end=' ')
print(y[n-1])
for i in range(1,n):
v = y[i]
j = i-1
while j >= 0 and y[j] > v:
y[j+1] = y[j]
j -= 1
y[j+1] = v
for j in range(n-1):
print(y[j],end='... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,990 |
s447997229 | p02255 | u596110276 | 1527781266 | Python | Python3 | py | Accepted | 20 | 5984 | 325 | def trace(A, N):
print(*A)
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
trace(A, N)
N = int(input())
A = list(map(int, input().split()))
trace(A, N)
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
| 30,991 |
s872388911 | p02255 | u990900604 | 1527844103 | Python | Python | py | Accepted | 10 | 4652 | 364 | #!/usr/bin/env python
#-*- coding: utf-8 -*-
if __name__ == '__main__':
raw_input()
l = map(int, raw_input().split())
for i in range(1, len(l)):
print ' '.join(map(str, l))
v = l[i]
j = i - 1
while j >= 0 and l[j] > v:
l[j + 1] = l[j]
j -= 1
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
| 30,992 |
s213866891 | p02255 | u777277984 | 1528260811 | Python | Python3 | py | Accepted | 30 | 5976 | 375 | def print_list(array, N):
for i, e in enumerate(array):
if i == N - 1:
print(e)
else:
print(e, end=" ")
N = int(input())
a = [int(e) for e in input().split()]
print_list(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[... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,993 |
s020233254 | p02255 | u722932083 | 1528327096 | Python | Python3 | py | Accepted | 20 | 5596 | 250 | 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
| 30,994 |
s653572410 | p02255 | u971076135 | 1528410744 | Python | Python3 | py | Accepted | 20 | 5608 | 393 | from sys import stdin
def stdinput():
return stdin.readline().strip()
def main():
n = int(stdinput())
a = list(map(int, stdinput().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
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,995 |
s134117565 | p02255 | u327546577 | 1528569675 | Python | Python3 | py | Accepted | 20 | 5604 | 255 | N = int(input())
L = [int(x) for x in 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
| 30,996 |
s907210740 | p02255 | u657361950 | 1528699290 | Python | Python3 | py | Accepted | 20 | 5984 | 350 | import sys
n = int(input())
arr = list(map(int, input().split()))
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
for i in range(n):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j = j - 1
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
| 30,997 |
s331123413 | p02255 | u657361950 | 1528700418 | Python | Python3 | py | Accepted | 20 | 5988 | 351 | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j = j - 1
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
| 30,998 |
s724629821 | p02255 | u867824281 | 1529023664 | Python | Python | py | Accepted | 10 | 4664 | 393 | import sys
n = input()
data = map(int, raw_input().split())
for i in range(1,n):
for k in range(0,n-1):
sys.stdout.write(str(data[k])+" ")
sys.stdout.write(str(data[n-1]))
print
temp = data[i]
j = i-1
while j >= 0 and data[j] > temp:
data[j+1] = data[j]
j = j - 1
data[j+1] = temp
for k in range(0,n-1):
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
| 30,999 |
s199576245 | p02255 | u657361950 | 1529027181 | Python | Python3 | py | Accepted | 20 | 5988 | 347 | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
arr[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,000 |
s870351524 | p02255 | u300095814 | 1529040696 | Python | Python3 | py | Accepted | 20 | 5592 | 292 | n = int(input())
list = list(map(int, input().split()))
print(' '.join(map(str,list)))
for i in range(1, n):
insertNum = list[i]
j = i - 1
while j >= 0 and list[j] > insertNum:
list[j+1] = list[j]
j-=1
list[j+1] = insertNum
print(' '.join(map(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,001 |
s016104684 | p02255 | u153665391 | 1529058802 | Python | Python3 | py | Accepted | 20 | 5600 | 315 | N = int(input())
A = list(map(int, input().split()))
if __name__ == '__main__':
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,002 |
s676843102 | p02255 | u148477094 | 1529070682 | Python | Python3 | py | Accepted | 20 | 5976 | 143 | n=int(input())
a=input().split()
for i in range(n):
k=int(a[i])
j=i-1
while j>=0 and int(a[j])>k:
a[j+1]=a[j]
j-=1
a[j+1]=k
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,003 |
s975478118 | p02255 | u298224238 | 1529091589 | Python | Python3 | py | Accepted | 20 | 5604 | 272 | N = int(input())
arr = [int(n) for n in input().split()]
print(' '.join(map(str, arr)))
for i in range(1, N):
v = arr[i]
j = i - 1
while(j >= 0 and arr[j] > v):
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = v
print(' '.join(map(str, 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,004 |
s266776556 | p02255 | u298224238 | 1529091933 | Python | Python3 | py | Accepted | 20 | 5604 | 272 | N = int(input())
arr = [int(n) for n in input().split()]
print(' '.join(map(str, arr)))
for i in range(1, N):
v = arr[i]
j = i - 1
while(j >= 0 and arr[j] > v):
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = v
print(' '.join(map(str, 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,005 |
s221803490 | p02255 | u657361950 | 1529285863 | Python | Python3 | py | Accepted | 20 | 5992 | 348 | import sys
def print_arr(arr):
for i in range(len(arr)):
sys.stdout.write(str(arr[i]))
if i != len(arr) - 1:
sys.stdout.write(' ')
print()
n = int(input())
arr = list(map(int, input().split()))
for i in range(n):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
arr[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,006 |
s762486486 | p02255 | u995990363 | 1529476816 | Python | Python3 | py | Accepted | 20 | 5608 | 406 | def insertionSort(A,N):
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]))
def run():
N = int(input())
A = [int(i) 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,007 |
s431981198 | p02255 | u929141425 | 1529482025 | Python | Python3 | py | Accepted | 20 | 5980 | 197 | 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,008 |
s933342754 | p02255 | u153665391 | 1529512377 | Python | Python3 | py | Accepted | 20 | 5600 | 462 | N = int(input())
A = list(map(int, input().split()))
if __name__ == '__main__':
print(" ".join(map(str, A)))
for i in range(1, N):
target_num = A[i]
for j in range(i):
if A[j] > target_num:
tmp_idx = i
while j < tmp_idx:
A[tmp_idx]... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,009 |
s807901925 | p02255 | u153665391 | 1529512410 | Python | Python3 | py | Accepted | 20 | 5600 | 342 | N = int(input())
A = list(map(int, input().split()))
if __name__ == '__main__':
print(" ".join(map(str, A)))
for i in range(1, N):
target_num = A[i]
j = i - 1
while j >= 0 and A[j] > target_num:
A[j+1] = A[j]
j -= 1
A[j+1] = target_num
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,010 |
s038329361 | p02255 | u922112509 | 1529553876 | Python | Python3 | py | Accepted | 30 | 5984 | 486 | # Insertion Sort
n = int(input())
integers = [int(i) for i in input().rstrip().split()]
def show(a):
for i in range(len(a)):
if i < len(a) - 1:
print(a[i], end = ' ')
return a[len(a) - 1]
def insertionSort(a, n):
for i in range(1, n):
print(show(a))
v = a[i]
j ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,011 |
s677788408 | p02255 | u445032255 | 1529831228 | Python | Python3 | py | Accepted | 20 | 5608 | 384 | def insertionSort(A, N):
print(" ".join(list(map(str, A))))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(list(map(str, A))))
def main():
N = int(input())
A = [int... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,012 |
s231509285 | p02255 | u605879293 | 1529904225 | Python | Python3 | py | Accepted | 20 | 5976 | 303 | def insertionSort(a):
n = len(a)
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)
n = int(input())
a = [int(x) for x in input().split()]
insertionSort(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,013 |
s984127092 | p02255 | u316584871 | 1530080471 | Python | Python3 | py | Accepted | 30 | 5980 | 355 | n = int(input())
nlist = list(map(int, input().split()))
for i in range(n):
j = i-1
v = nlist[i]
while (j >= 0 and nlist[j] > v):
nlist[j+1] = nlist[j]
j -= 1
nlist[j+1] = v
for k in range(n):
if (k == n-1):
print(nlist[k], end = '')
else:
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,014 |
s021356610 | p02255 | u418996726 | 1530132555 | Python | Python3 | py | Accepted | 20 | 5592 | 294 | N = int(input())
arr = list(map(int, input().split()))
for i in range(len(arr)):
for j in range(i,0,-1):
if(arr[j] < arr[j-1]):
temp = arr[j]
arr[j] = arr[j-1]
arr[j-1] = temp
else:
continue
print(' '.join(map(str,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,015 |
s615620392 | p02255 | u320121447 | 1530362010 | Python | Python3 | py | Accepted | 30 | 5612 | 438 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def insertionSort(A, N):
"""N個の要素を含む0-オリジンの配列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(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,016 |
s039505261 | p02255 | u646764397 | 1530407240 | Python | Python3 | py | Accepted | 20 | 5608 | 232 | N = int(input())
a = input().split()
b = [int(n) for n in a]
for i in range(N):
v = b[i]
j = i-1
while j>=0 and b[j]>v:
b[j+1] = b[j]
j = j-1
b[j+1] = v
print(" ".join([str(n) for n in 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,017 |
s530406272 | p02255 | u677291728 | 1530600034 | Python | Python3 | py | Accepted | 40 | 5980 | 406 | def print_row (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()))
print_row(nums)
for i in range(1,n):
v = nums[i]
j = i - 1
while (j >= 0 and 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,018 |
s187203218 | p02255 | u763301852 | 1363456047 | Python | Python | py | Accepted | 10 | 4240 | 373 | def main():
N = int(raw_input())
A = map(int, raw_input().split())
sort(A)
def sort(A):
N = len(A)
display(A)
for j in range(1, N):
key = A[j]
i = j - 1
while i >= 0 and A[i] > key:
A[i+1] = A[i]
i -= 1
A[i+1] = key
display(A)
def... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,019 |
s638538594 | p02255 | u912237403 | 1371256170 | Python | Python | py | Accepted | 10 | 4236 | 331 | def trace(x):
for e in x:
print e,
print
n = input()
x = map(int, raw_input().split())
trace(x)
for j in range(1, n):
key = x[j]
for i in range(j)[::-1]:
if x[i] > key:
x[i+1] = x[i]
else:
i += 1
break
else:
i = 0
x[i] = key
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,020 |
s496084608 | p02255 | u782850731 | 1379654802 | Python | Python | py | Accepted | 20 | 4236 | 331 | #!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin
stdin.readline()
ar = [int(s) for s in stdin.readline().split()]
print(*ar)
for j in range(1, len(ar)):
key = ar[j]
i = j - 1
while i >= 0 and ar[i] > key:
ar[i+1] = ar[i]
i -= 1
ar[i+1] = key
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,021 |
s538223029 | p02255 | u140201022 | 1382459913 | Python | Python | py | Accepted | 20 | 4568 | 382 | #!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import time
import sys
import io
import re
import math
#i = 0
N=int(raw_input())
l=map(int, raw_input().split())
print ' '.join(map(str, l))
for j in range(1,len(l)):
key=l[j]
i=j-1
while i>=0 and l[i] > key:
l[i+1]=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,022 |
s320233185 | p02255 | u231998559 | 1387349910 | Python | Python | py | Accepted | 10 | 4220 | 228 | n = input()
a = map(int, raw_input().split())
print ' '.join(map(str, a))
for j in range(1, len(a)):
key = a[j]
i = j - 1
while (i > -1) and (a[i] > key):
a[i+1] = a[i]
i = i - 1
a[i+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,023 |
s746919519 | p02255 | u063179562 | 1390218494 | Python | Python | py | Accepted | 20 | 4220 | 248 | n = int(raw_input())
A = map(int,raw_input().split())
print " ".join(map(str,A))
for j in range(1,n):
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 " ".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,024 |
s923303997 | p02255 | u904989881 | 1391583528 | Python | Python | py | Accepted | 20 | 4216 | 237 | N = input()
A = map(int,raw_input().split())
print ' '.join(map(str,A))
for j in range(1,N):
key = A[j]
i = j - 1
while i >= 0 and A[i] > key:
A[i+1] = A[i]
i -= 1
A[i+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,025 |
s609968322 | p02255 | u633068244 | 1393695809 | Python | Python | py | Accepted | 20 | 4220 | 252 | n = int(raw_input())
a = map(int, raw_input().split())
print " ".join(map(str, a))
for j in range(1,n):
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 " ".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,026 |
s776691938 | p02255 | u633068244 | 1393696018 | Python | Python | py | Accepted | 10 | 4224 | 316 | def isort(n,a):
print " ".join(map(str, a))
for j in range(1,n):
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 " ".join(map(str, a))
n = int(raw_input())
a = map(int, raw_input().split())
isort(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,027 |
s896697191 | p02255 | u633068244 | 1393696083 | Python | Python | py | Accepted | 20 | 4224 | 313 | def isort(n,a):
p(a)
for j in range(1,n):
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
p(a)
def p(a):
print " ".join(map(str, a))
n = int(raw_input())
a = map(int, raw_input().split())
isort(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,028 |
s559966417 | p02255 | u633068244 | 1393741828 | Python | Python | py | Accepted | 20 | 4220 | 258 | n = int(raw_input())
a = map(int, raw_input().split())
print " ".join(map(str, 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 " ".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,029 |
s195820075 | p02255 | u387077254 | 1396507947 | Python | Python | py | Accepted | 20 | 4232 | 437 | def insertion_sort(A, N):
for j in range(1, N):
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 " ".join(map(str, A))
if __name__ == "__main__":
import sys
N = int(sys.stdin.readline().strip())
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,030 |
s395430551 | p02255 | u436634575 | 1400759228 | Python | Python3 | py | Accepted | 40 | 6720 | 271 | n = int(input())
a = list(map(int, input().strip().split()))
for i in range(1, len(a)):
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,031 |
s980198465 | p02255 | u242221792 | 1597904333 | Python | Python3 | py | Accepted | 20 | 5980 | 279 | num = int(input())
number_list = list(map(int, input().split(" ")))
for i in range(num):
v = number_list[i]
j = i - 1
while j >= 0 and number_list[j] > v:
number_list[j + 1] = number_list[j]
j -= 1
number_list[j + 1] = v
print(*number_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,032 |
s435074798 | p02255 | u995254364 | 1597814653 | Python | Python3 | py | Accepted | 20 | 5596 | 248 | n = int(input())
N = list(map(int,input().split()))
ans = list(map(str,N))
print(" ".join(ans))
for i in range(n-1):
v = N[i+1]
j = i
while j >= 0 and N[j] > v:
N[j+1] = N[j]
j -= 1
N[j+1] = v
ans = list(map(str,N))
print(" ".join(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,033 |
s445514649 | p02255 | u018707296 | 1597748405 | Python | Python3 | py | Accepted | 30 | 5956 | 334 | n=int(input())
a=[int(x) for x in input().split()]
for j in range(n):
if j<n-1:
print(a[j],end=" ")
else:
print(a[j])
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 j in range(n):
if j<n-1:
print(a[j],end=" ")
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,034 |
s388184362 | p02255 | u009468286 | 1597654128 | Python | Python3 | py | Accepted | 20 | 5984 | 289 | def insertion_sort(a, n):
print(*a)
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1], a[j] = a[j], a[j+1]
j -= 1
print(*a)
n = int(input())
a = list(map(int, input().split()))
insertion_sort(a, n)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,035 |
s695636397 | p02255 | u919570352 | 1597576993 | Python | Python3 | py | Accepted | 20 | 5980 | 169 | 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,036 |
s067528992 | p02255 | u571995157 | 1597487304 | Python | Python3 | py | Accepted | 20 | 5984 | 338 | 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)
if __name__ == "__main__":
N = int(input())
A = list(map(int, input().split()))
print(*A)
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,037 |
s745537002 | p02255 | u781215638 | 1597367267 | Python | Python3 | py | Accepted | 20 | 5596 | 215 | 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]
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,038 |
s293998369 | p02255 | u823513038 | 1597301913 | Python | Python3 | py | Accepted | 30 | 5596 | 269 | N = int(input())
A = list(map(int, input().split()))
for i in range(N):
x = A[i]
for j in range(i, -1, -1):
if j != 0 and A[j - 1] > x:
A[j] = A[j - 1]
else:
A[j] = x
break
s = ""
for j in range(N):
if j != 0:
s += " "
s += str(A[j])
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,039 |
s176997077 | p02255 | u104777289 | 1597218070 | Python | Python3 | py | Accepted | 20 | 5600 | 742 | n = int(input())
a = list(map(int, input().split()))
def output(a):
print(" ".join(map(str, a)))
def insertionSort(a:list, n:int):
for i in range(1, n):
now = a[i] #未ソート部分の先頭(未ソート部分の左端)
j = i - 1 #jはiのひとつ前から始まる
while j >= 0 and a[j] > now: #未ソート部分の先頭(now)より左にあり、かつnowよりも大きい要素を後方に移動するため... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,040 |
s385332576 | p02255 | u261371912 | 1597214450 | Python | Python3 | py | Accepted | 40 | 5984 | 379 | n = int(input())
a = input().split()
for s in range(len(a)-1):
print(a[s],end=' ')
print(a[-1])
for i in range(1,n):
x = int(a[i])
j = i-1
while j >=0 and int(a[j])>x:
t = int(a[j])
r = int(a[j+1])
a[j+1] = t
a[j] = r
j -=1
s = 0
for s in range(len(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,041 |
s761104219 | p02255 | u333677472 | 1597135786 | Python | Python3 | py | Accepted | 30 | 5984 | 324 | n = int(input())
A = [int(x) for x in input().split()]
for i in range(n):
v = A[i]
j = i-1
for j in range(i-1,-1,-1):
if (A[j] > v):
A[j+1] = A[j]
A[j] = v
else :
break
for k in range(n-1):
print(str(A[k])+" ",end = "")
print(str(A[n-1]... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,042 |
s488667416 | p02255 | u001262101 | 1597109703 | Python | Python3 | py | Accepted | 30 | 5980 | 531 | num = int(input())
num_list = list(map(int, input().split(" ")))
for x in range(len(num_list)):
if x == len(num_list) - 1:
print(num_list[x])
else:
print(num_list[x],end=" ")
for i in range(1, num):
v = num_list[i]
j = i - 1
while j >= 0 and num_list[j] > v:
num_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,043 |
s489984234 | p02255 | u426591286 | 1597057831 | Python | Python3 | py | Accepted | 40 | 6804 | 608 | import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): 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,044 |
s819562549 | p02255 | u129428695 | 1597034304 | Python | Python3 | py | Accepted | 20 | 5608 | 243 | 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,045 |
s800773325 | p02255 | u707364330 | 1597023632 | Python | Python3 | py | Accepted | 20 | 5604 | 429 | def main():
n = int(input())
nums = input()
print(nums)
nums = nums.split(' ')
nums = [int(i) for i in nums]
insertion_sort(n, nums)
def insertion_sort(n, 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 -... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,046 |
s593187422 | p02255 | u799886576 | 1596985595 | 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,047 |
s182166497 | p02255 | u215733299 | 1596968369 | Python | Python3 | py | Accepted | 40 | 5976 | 440 | #挿入ソート
#A[i] i = 1-n でソート済み箇所をiで指定
#A[j] j = 0-i でA[i]より大きな値が出てくるまで走査
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
for i in range(n):
if i < n-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,048 |
s187985347 | p02255 | u775765468 | 1596931594 | Python | Python3 | py | Accepted | 20 | 5604 | 363 | N = int(input())
lst = list(map(int,input().split()))
def insertionSort(A,N):
print(" ".join(map(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] = 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,049 |
s323125693 | p02255 | u747915832 | 1596893646 | Python | Python3 | py | Accepted | 30 | 5980 | 512 | N = int(input())
S = list(map(int, input().split()))
for i in range(N):
if i==N-1:
print(S[i])
else:
print(S[i],end=' ')
for i in range(1,N):
key = S[i]
if key < max(S[0:i]):
S.pop(i)
x = 0
for k in range(i):
if x==1:
continue
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,050 |
s516244531 | p02255 | u123158238 | 1596874453 | Python | Python3 | py | Accepted | 20 | 5604 | 261 | n = int(input())
L = list(map(int, input().split()))
for i in range(1, n):
print(' '.join(str(x) for x in L))
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(str(x) for x in 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,051 |
s521829527 | p02255 | u652209331 | 1596810235 | Python | Python3 | py | Accepted | 20 | 5608 | 286 | N = int(input())
A = [int(n) for n in input().split()]
print(" ".join([str(a) for a in A]))
# insertionSort
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,052 |
s052862679 | p02255 | u773595479 | 1596804960 | Python | Python3 | py | Accepted | 30 | 5600 | 314 | N = int(input())
A = list(map(int,input().split()))
def show_step(A):
ans = str(A[0])
for a in A[1:]:
ans += " "+str(a)
print(ans)
show_step(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_step(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,053 |
s992554500 | p02255 | u905896226 | 1596724167 | Python | Python3 | py | Accepted | 30 | 5600 | 260 | n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
print(' '.join(map(str, A)))
temp = A[i]
j = i - 1
while A[j] > temp and j >= 0:
A[j + 1] = A[j]
j -= 1
A[j + 1] = temp
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,054 |
s236638345 | p02255 | u255211353 | 1596701052 | Python | Python3 | py | Accepted | 20 | 5596 | 237 | n = int(input())
nums = list(map(int, input().split()))
for i in range(n):
v = nums[i]
j = i - 1
while j >= 0 and nums[j] > v:
nums[j+1] = nums[j]
j -= 1
nums[j+1] = v
print(' '.join(map(str, nums)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,055 |
s282441402 | p02255 | u309196579 | 1596505423 | Python | Python3 | py | Accepted | 20 | 5980 | 192 | N = int(input())
A = [*map(int, input().split())]
for i in range(N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,056 |
s173651806 | p02255 | u254617460 | 1596505420 | Python | Python3 | py | Accepted | 30 | 5596 | 242 | N = int(input())
A = list(map(int, input().split()))
print(' '.join(map(str, 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(' '.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,057 |
s615432880 | p02255 | u793520502 | 1596441818 | Python | Python3 | py | Accepted | 40 | 6316 | 913 | import sys
def print_data(data):
last_index = len(data) - 1
for idx, item in enumerate(data):
print(item, end='')
if idx != last_index:
print(' ', end='')
print('')
def main():
N = int(input())
A_list = list(map(int, input().split()))
nowmax = -1
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,058 |
s908427755 | p02255 | u423804722 | 1596438115 | Python | Python3 | py | Accepted | 20 | 5596 | 310 | N = int(input())
A = list(map(int, input().split()))
print(str(A).replace('[', '').replace(']', '').replace(',', ''))
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(str(A).replace('[', '').replace(']', '').replace(',', ''))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,059 |
s461478020 | p02255 | u898470141 | 1596354083 | Python | Python3 | py | Accepted | 20 | 5608 | 235 | N = int(input())
a = list(map(int, input().split()))
for i in range(N):
key = a[i]
j = i - 1
while j >= 0 and a[j] > key:
a[j + 1] = a[j]
j -= 1
a[j + 1] = key
print(" ".join([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,060 |
s414142901 | p02255 | u733357255 | 1596261833 | Python | Python3 | py | Accepted | 20 | 5976 | 189 | n = int(input())
a = list(map(int,input().split()))
print(*a)
for i in range(n-1):
j = i
while a[j]>a[j+1] and j>=0:
a[j],a[j+1] = a[j+1],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,061 |
s006789594 | p02255 | u881400496 | 1595944075 | Python | Python3 | py | Accepted | 20 | 5980 | 216 | n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
v = lst[i]
j = i - 1
while j >=0 and lst[j] > v:
lst[j + 1] = lst[j]
j -= 1
lst[j + 1] = v
print(*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,062 |
s479005944 | p02255 | u741657101 | 1595917938 | Python | Python3 | py | Accepted | 20 | 5980 | 251 | a= int(input())
x =[int(z) for y, z in enumerate(input().split()) if y < a and z.isdigit()]
print(*x)
for i in range(1,a):
key = x[i]
j = i-1
while j >= 0 and x[j] > key:
x[j+1] = x[j]
j -= 1
x[j+1] = key
print(*x)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,063 |
s943462040 | p02255 | u849859490 | 1595730798 | Python | Python3 | py | Accepted | 30 | 6312 | 393 | N = int(input())
number = list(map(int,input().split()))
def show(A):
for t in range(len(A)):
if t != N -1:
print(number[t],'',end='')
else:
print(number[t])
for i in range(1,N):
show(number)
v = number[i]
j = i -1
while j >= 0 and number[j] > v:
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,064 |
s226320923 | p02255 | u459368238 | 1595728225 | Python | Python3 | py | Accepted | 30 | 5976 | 422 | def insertionSort(A, N):
for i in range(1, N):
for j in range(N - 1):
print(A[j], end=' ')
print(A[-1])
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
for j in range(N - 1):
print(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,065 |
s615688743 | p02255 | u828164095 | 1595588584 | Python | Python3 | py | Accepted | 30 | 5608 | 425 | def print_list(nums):
output = ""
for i in nums:
output += str(i) + ' '
print(output[:-1])
from sys import stdin
N = int(input())
nums = list(map(lambda x:int(x), stdin.readline().split(' ')))
for i in range(1, N):
print_list(nums)
num = nums[i]
for j in range(0, i):
if 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,066 |
s351348803 | p02255 | u822891605 | 1595580564 | Python | Python3 | py | Accepted | 20 | 5604 | 262 | N = int(input())
A = [ int(v) for v in input().split(" ") ]
for i in range(len(A)):
while i > 0:
if A[i] < A[i-1]:
A[i], A[i-1] = A[i-1], A[i]
i -= 1
else:
break
print (" ".join([str(v) for v 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,067 |
s708540310 | p02255 | u410978079 | 1595329849 | Python | Python3 | py | Accepted | 20 | 5604 | 499 | # coding: utf-8
# Your code here!
def insert_sort(arr):
for index in range(1, len(arr)):
insert(index, arr)
def insert(index, arr):
tmp = arr[index]
for i in range(index-1, -1, -1):
if arr[i] > tmp:
arr[i + 1] = arr[i]
arr[i] = tmp
else:
arr[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,068 |
s355005417 | p02255 | u729823147 | 1595328831 | Python | Python3 | py | Accepted | 20 | 5604 | 273 | n = int(input())
a = (list(map(int, input().split())))
print(' '.join(list(map(str, a))))
for i in range(1, n):
key = a[i]
j = i - 1
while j >= 0 and a[j] > key:
a[j + 1] = a[j]
j -= 1
a[j + 1] = key
print(' '.join(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,069 |
s864663032 | p02255 | u474889652 | 1595308806 | Python | Python3 | py | Accepted | 30 | 5976 | 522 | def insertionSort(A,N):
for i in range(1,N):
v=A[i]
j=i-1
while (j>=0 and A[j]>v):
c=A[j+1]
A[j+1]=A[j]
A[j]=c
j-=1
for i in range(len(A)):
if i!=len(A)-1:
print(A[i],end=" ")
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,070 |
s335981463 | p02255 | u210251354 | 1595287664 | Python | Python3 | py | Accepted | 20 | 5600 | 386 | num = int(input())
list = list(map(int,input().split()))
list_str = []
for i in list:
list_str.append(str(i))
print(" ".join(list_str))
for i in range(1,num):
v = list[i]
j = i - 1
while j>= 0 and list[j]>v:
list[j+1] = list[j]
j -= 1
list[j+1] = v
list_str = []
for i in lis... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,071 |
s501629254 | p02255 | u141099640 | 1595220755 | Python | Python3 | py | Accepted | 20 | 5596 | 260 | n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
print(' '.join(map(str, A)))
temp = A[i]
j = i - 1
while A[j] > temp and j >= 0:
A[j + 1] = A[j]
j -= 1
A[j + 1] = temp
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,072 |
s623252638 | p02255 | u164230325 | 1595134959 | Python | Python3 | py | Accepted | 20 | 5984 | 253 | 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,073 |
s751492252 | p02255 | u053513395 | 1595074845 | Python | Python3 | py | Accepted | 20 | 5992 | 570 | #-*-coding:utf-8-*-
import sys
input=sys.stdin.readline
def main():
n = int(input())
numbers=[]
numbers=list(map(int,input().split()))
print(*numbers)
for i in range(1,n):
#key is numbers value.when starting numbers[1].
key = numbers[i]
#j is numbers startpoint.when starting... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,074 |
s543000710 | p02255 | u802474686 | 1595066320 | Python | Python3 | py | Accepted | 20 | 5600 | 210 | n=int(input())
lst=list(map(int,input().split()))
for i in range(n):
a=lst[i]
j=i-1
while j>=0 and lst[j]>a:
lst[j+1]=lst[j]
j-=1
lst[j+1]=a
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,075 |
s705924261 | p02255 | u896150184 | 1594952330 | Python | Python3 | py | Accepted | 20 | 5596 | 215 | 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,076 |
s589823820 | p02255 | u914515588 | 1594735365 | Python | Python3 | py | Accepted | 50 | 7700 | 1,192 | import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque
sys.setrecursionlimit(10000000)
ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(i... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,077 |
s564092257 | p02255 | u972252150 | 1594650615 | Python | Python3 | py | Accepted | 20 | 5600 | 265 | N = int(input())
A = list(map(int, input().split()))
print(' '.join(str(a) for a in A))
for i in range(1, N):
v = A[i]
j = i - 1
while 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,078 |
s415993592 | p02255 | u525366883 | 1594558651 | Python | Python3 | py | Accepted | 20 | 5604 | 270 | n = int(input())
num = list(map(int, input().split()))
cnt = 1
print(" ".join(map(str,num)))
while cnt < len(num):
for i in range(cnt, 0, -1):
if num[i] < num[i-1]:
num[i], num[i-1] = num[i-1], num[i]
print(" ".join(map(str,num)))
cnt+=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,079 |
s665491287 | p02255 | u574014462 | 1594532042 | Python | Python3 | py | Accepted | 30 | 5608 | 441 | # coding: utf-8
# Your code here!
def insert_sort(A:list) -> list:
for i in range(1, len(A)):
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
return A
if __name__ == '__main__':
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,080 |
s288289608 | p02255 | u170149447 | 1594451011 | Python | Python3 | py | Accepted | 20 | 5600 | 338 | def insertionSort(A, N):
for i in range(1, N):
pri_lst(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
def pri_lst(A):
print(" ".join(map(str,A)))
N = int(input())
A = list(map(int,input().split()))
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,081 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.