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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s410463577 | p02255 | u197445199 | 1442211303 | Python | Python | py | Accepted | 30 | 6464 | 370 | num = int(raw_input())
line = raw_input()
A = line.strip().split(" ")
print " ".join(A)
#A = map(int, item_str)
for i in range(1, num):
v = int(A[i])
j = i - 1
for j in range(j, -1, -1):
if int(A[j]) > v:
A[j+1] = A[j]
j -= 1
else:
break
A[j+1] = 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
| 30,582 |
s695866161 | p02255 | u885889402 | 1442217186 | Python | Python3 | py | Accepted | 40 | 8432 | 500 | def insertionSort(a,n):
for i in range(n):
print(a[i],end="")
if(i!=n-1):
print(" ",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):
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,583 |
s953073657 | p02255 | u313994256 | 1442284022 | Python | Python | py | Accepted | 10 | 6336 | 297 | N = int(raw_input())
num_list = map(int, raw_input().split())
print " ".join(map(str,num_list))
for i in range(1, N):
v = num_list[i]
j = i - 1
while j >= 0 and num_list[j] > v:
num_list[j+1] = num_list[j]
j-=1
num_list[j+1] = v
print " ".join(map(str,num_list)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,584 |
s746269194 | p02255 | u253463900 | 1442284042 | Python | Python3 | py | Accepted | 30 | 7928 | 360 | n = int(input())
A = []
s = input()
A = list(map(int,s.split()))
for i in range(1,len(A)):
v = A[i]
j = i-1
for k in range(0,len(A)-1):
print(A[k],end=" ")
print(A[len(A)-1])
while(j >= 0 and A[j] > v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
for k in range(0,len(A)-1):
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,585 |
s902272720 | p02255 | u237991875 | 1442285003 | Python | Python | py | Accepted | 20 | 6348 | 323 | numbers = []
n = raw_input()
s = raw_input()
print s
numbers = s.split(" ")
for i in range(int(n)):
numbers[i] = int(numbers[i])
for i in range(1, int(n)):
v = numbers[i]
j = i - 1
while (j >= 0 and numbers[j] > v):
numbers[j + 1] = numbers[j]
j -= 1
numbers[j + 1] = v
print ' '.join([str(a) for a in number... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,586 |
s532120951 | p02255 | u894381890 | 1442292461 | Python | Python | py | Accepted | 10 | 6360 | 465 | import sys
def insertionSort(x_list,y):
for i in range(1, y):
v = x_list[i]
j = i - 1
while j >= 0 and x_list[j] > v:
x_list[j + 1] = x_list[j]
j -= 1
x_list[j+1] = v
for k in range(0, y):
print x_list[k],
print
y = sys.stdin.readline()
y = int(y)
x = sys.stdin.readline()
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,587 |
s281591611 | p02255 | u386372280 | 1442292723 | Python | Python | py | Accepted | 10 | 6296 | 282 | import sys
lines = sys.stdin.readlines()
N = lines[0]
A = lines[1].strip().split(" ")
print " ".join(A)
for i in range(1, len(A)):
key = A[i]
j = i - 1
while j >= 0 and int(A[j]) > int(key):
A[j+1] = A[j]
j -= 1
A[j+1] = key
print " ".join(A) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,588 |
s601247524 | p02255 | u019737947 | 1442292783 | Python | Python | py | Accepted | 10 | 6252 | 241 | N = int(raw_input())
A = raw_input().split(" ")
print " ".join(A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and int(A[j]) > int(v):
A[j+1] = A[j]
j = j - 1
A[j+1] = v
print " ".join(A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,589 |
s296198512 | p02255 | u854228079 | 1442315954 | Python | Python | py | Accepted | 10 | 6320 | 394 |
n = raw_input()
num = raw_input()
array = []
array = num.strip().split(" ")
int_array = map(int, array)
for i in range(1, int(n)):
array = map(str, int_array)
print " ".join(array)
v = int_array[i]
j = i - 1
while j >= 0 and int_array[j] > v:
int_array[j + 1] = int_array[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,590 |
s587747353 | p02255 | u072053884 | 1442630015 | Python | Python3 | py | Accepted | 20 | 7640 | 304 | n = input()
n = int(n)
numbers = input()
numbers = numbers.split(' ')
for i in range(1, n):
print(" ".join(numbers))
j = i - 1
while (j >= 0) and (int(numbers[j]) > int(numbers[j + 1])):
numbers[j], numbers[j + 1] = numbers[j + 1], numbers[j]
j -= 1
print(" ".join(numbers)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,591 |
s033328658 | p02255 | u520845247 | 1443291033 | Python | Python3 | py | Accepted | 20 | 8112 | 260 | input()
xs = list(map(int, input().split()))
def insertion_sort(xs):
for i in range(1, len(xs)):
v = xs[i]
j = i - 1
while j >= 0 and xs[j] > v:
xs[j + 1] = xs[j]
j -= 1
xs[j + 1] = v
print(*xs)
print(*xs)
insertion_sort(xs) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,592 |
s508734328 | p02255 | u240363515 | 1443920685 | Python | Python | py | Accepted | 10 | 6412 | 213 | N = input()
A = map(int, raw_input().split())
for i in range(len(A)):
v = A[i]
j = i - 1
while (j >= 0) & (A[j] > v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print ' '.join(map(str, A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,593 |
s935532332 | p02255 | u224288634 | 1445565498 | Python | Python | py | Accepted | 30 | 6476 | 321 | import copy
def insertion_sort(List):
l=len(List)
for i in range(l):
for j in range(i):
if List[i]<List[j]:
temp=copy.copy(List)
for k in range(j,i):
List[k+1]=temp[k]
List[j]=temp[i]
break
print(" ".join(map(str,List)))
N=input()
N_List=map(int,raw_input().split())
insertion_sort(N_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
| 30,594 |
s438807811 | p02255 | u766163292 | 1446298714 | Python | Python3 | py | Accepted | 20 | 7708 | 491 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
def print_array(a):
print(" ".join(map(str, a)))
def insertion_sort(a, n):
print_array(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
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,595 |
s953447950 | p02255 | u742797815 | 1446396343 | Python | Python3 | py | Accepted | 20 | 8148 | 203 | n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
a = l[i]
j = i - 1
while j >= 0 and l[j] > a:
l[j+1] = l[j]
j = j - 1
l[j+1] = a
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
| 30,596 |
s327297004 | p02255 | u630746844 | 1446700252 | Python | Python3 | py | Accepted | 30 | 8084 | 496 | import sys
def insertionSort(A, N):
for n in range(N-1):
print (A[n], end=" ")
print(A[N-1])
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
for n in range(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
| 30,597 |
s263970067 | p02255 | u960191521 | 1447259407 | Python | Python | py | Accepted | 10 | 6364 | 228 | n = int(input())
a = list(map(int, raw_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(s) for s 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
| 30,598 |
s331888567 | p02255 | u488601719 | 1448700571 | Python | Python3 | py | Accepted | 20 | 8096 | 290 | N = int(input())
A = list(map(int, input().split()))
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)
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
| 30,599 |
s332895644 | p02255 | u825618558 | 1450006609 | Python | Python3 | py | Accepted | 70 | 8164 | 639 | import sys
def display(inp):
s = len(inp)
for i in range(s):
if i!=len(inp)-1:
print("%d" % inp[i], end=" ")
else:
print("%d" % inp[i], end="")
print("")
line = sys.stdin.readline()
size = int(line)
line = sys.stdin.readline()
inp = []
for i in line.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
| 30,600 |
s403134122 | p02255 | u222323200 | 1450104641 | Python | Python3 | py | Accepted | 40 | 8032 | 400 | n = int(input())
array = [int(a) for a in input().split()]
for i in range(n):
j = i
while j < n:
if j != 0 and array[j-1] > array[j]:
array[j-1], array[j] = array[j], array[j-1]
j -= 1
continue
else:
break
for k in range(n):
if k != 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
| 30,601 |
s092052441 | p02255 | u966364923 | 1450159345 | Python | Python3 | py | Accepted | 30 | 8084 | 305 | def insertionsSort(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)
N = int(input())
A = list(map(int, input().split()))
insertionsSort(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,602 |
s067474889 | p02255 | u797673668 | 1452333009 | Python | Python3 | py | Accepted | 30 | 7640 | 252 | n, a = int(input()), 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,603 |
s828532405 | p02255 | u321017034 | 1453385322 | Python | Python3 | py | Accepted | 20 | 7760 | 370 | def insertionSort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join(map(str, A)))
if __name__ == "__main__":
n = int(input())
a = [int(e) for e in input().split()]
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,604 |
s860196821 | p02255 | u529386725 | 1453721250 | Python | Python3 | py | Accepted | 40 | 7688 | 258 | N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(list(map(str, A)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,605 |
s467871117 | p02255 | u341533698 | 1454339391 | Python | Python | py | Accepted | 30 | 6472 | 319 | def main():
N = input()
a = map(int, raw_input().split())
print ' '.join(map(str,a))
for i in xrange(1,len(a)):
v = a[i]
j = i - 1
while (j >= 0) & (a[j] > v):
a[j+1] = a[j]
j -= 1
a[j+1] = v
print ' '.join(map(str,a))
return 0
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
| 30,606 |
s018274293 | p02255 | u731710433 | 1454832178 | Python | Python3 | py | Accepted | 20 | 7712 | 314 | input()
array = [int(x) for x in input().split()]
print(' '.join(list(str(x) for x in array)))
for i in range(1, len(array)):
key = array[i]
j = i - 1
while j >= 0 and array[j] > key:
array[j + 1] = array[j]
j -= 1
array[j + 1] = key
print(' '.join(list(str(x) for x in array))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,607 |
s222421211 | p02255 | u567281053 | 1456060485 | Python | Python | py | Accepted | 10 | 6332 | 378 | def insertionSort(A, N):
print " ".join([str(t) for t 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(t) for t in A])
if __name__ == "__main__":
N = 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
| 30,608 |
s325841149 | p02255 | u424209323 | 1456297786 | Python | Python | py | Accepted | 10 | 6332 | 368 | def insertionSort(R, n):
for i in range(1, n):
Now = R[i]
j = i - 1
while j >= 0 and R[j] > Now:
R[j + 1] = R[j]
j = j - 1
R[j + 1] = Now
trace(R, n)
def trace(R, n):
for i in range(n):
print R[i],
print
n = input()
R = map(int, raw_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
| 30,609 |
s392417038 | p02255 | u923973323 | 1456576190 | Python | Python3 | py | Accepted | 30 | 7704 | 532 | n = input()
data = [int(i) for i in input().split(' ')]
def insertion_sort(raw_list):
for i, v in enumerate(raw_list):
if i == 0:
continue
j = i - 1
while j >= 0 and v < raw_list[j]:
raw_list[j+1] = v
raw_list[j+1] = raw_list[j]
j -= 1
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,610 |
s510381492 | p02255 | u894114233 | 1456727177 | Python | Python | py | Accepted | 20 | 6444 | 278 | def trace() :
li=[]
for i in xrange(n):
li.append(str(a[i]))
print(" ".join(li))
n=input()
a=map(int,raw_input().split())
for i in xrange(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()
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,611 |
s619358721 | p02255 | u233232390 | 1456760730 | Python | Python | py | Accepted | 10 | 6372 | 247 | n = int(raw_input())
A = map(int,raw_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
| 30,612 |
s791113661 | p02255 | u975539923 | 1457144882 | Python | Python | py | Accepted | 10 | 6468 | 435 | def insertionSort(a, n):
for i in range(1, n):
show(a, 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
else:
show(a, n)
def show(a, n):
for i in range(n):
if i == n-1:
print "%d" % 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,613 |
s232544669 | p02255 | u650459696 | 1458908539 | Python | Python3 | py | Accepted | 30 | 8092 | 212 | n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
print(*a)
t = a[i]
j = i - 1
while j >= 0 and a[j] > t:
a[j + 1] = a[j]
j -= 1
a[j + 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
| 30,614 |
s967113165 | p02255 | u512342660 | 1458928267 | Python | Python | py | Accepted | 10 | 6444 | 267 | def printlist(al):
print " ".join(map(str,al))
l = input()
al = map(int,raw_input().split())
printlist(al)
for i in xrange(1,l):
v = al[i]
j = i-1
while j >= 0 and al[j]>v:
al[j+1] = al[j]
j-=1
al[j+1]=v
printlist(al) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,615 |
s117792021 | p02255 | u026681847 | 1459106023 | Python | Python3 | py | Accepted | 20 | 7736 | 328 | def insertionSort(At, Nt):
for i in range(Nt):
v = At[i]
j = i - 1
while j >= 0 and At[j] > v:
A[j + 1] = A[j]
j = j - 1
A[j + 1] = v
print(" ".join(map(str,At)))
return At
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
A = insertionSort(A, N)
#print(" ".join(map(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,616 |
s104525102 | p02255 | u779638168 | 1459437192 | Python | Python | py | Accepted | 10 | 6392 | 285 | N = input()
l = map(int, raw_input().split())
i = 1
while i < N:
l_str = map(str,l)
print " ".join(l_str)
tmp = l[i]
j = i - 1
while j >= 0 and tmp < l[j]:
l[j + 1] = l[j]
j -= 1
l[j + 1] = tmp
i += 1
l_str = map(str,l)
print " ".join(l_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
| 30,617 |
s769844251 | p02255 | u130979865 | 1459668299 | Python | Python | py | Accepted | 30 | 6448 | 238 | # -*- coding: utf-8 -*-
N = int(raw_input())
A = map(int, raw_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
| 30,618 |
s769476775 | p02255 | u572790226 | 1459874031 | Python | Python3 | py | Accepted | 20 | 7748 | 257 | 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
| 30,619 |
s459788819 | p02255 | u763534154 | 1460374960 | Python | Python | py | Accepted | 10 | 6488 | 346 | from __future__ import division, print_function, unicode_literals
from future_builtins import *
N = int(raw_input())
A = list(map(int, raw_input().split()))
print(" ".join(map(str, A)))
for i in xrange(1,N):
j, p = i-1, A[i]
while j >= 0 and A[j] > p:
A[j+1] = A[j]
j -= 1
A[j+1] = p
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,620 |
s331689025 | p02255 | u734765925 | 1462618526 | Python | Python3 | py | Accepted | 30 | 7660 | 256 | n = int(input())
A = list(map(int,input().split()))
temp = 0
print(" ".join(map(str,A)))
for i in range(1,n):
temp = A[i]
j = i -1
while j >=0 and A[j] > temp :
A[j+1]=A[j]
j-=1
A[j+1] = temp
print(" ".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,621 |
s398943414 | p02255 | u182913399 | 1463635295 | Python | Python3 | py | Accepted | 20 | 7668 | 264 | n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
print(' '.join(list(map(str, a))))
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(' '.join(list(map(str, a)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,622 |
s688760155 | p02255 | u003309334 | 1464056118 | Python | Python | py | Accepted | 10 | 6340 | 391 | def insertionSort(A, N):
for i in xrange(1, N):
printList(A, 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
return A
def printList(A, N):
for i in xrange(N):
print A[i],
print
# MAIN
N = input()
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,623 |
s915251978 | p02255 | u760369990 | 1464063252 | Python | Python3 | py | Accepted | 30 | 7724 | 270 | data_num = int(input())
data = [int(n) for n in input().split(' ')]
for i in range(0, data_num):
v = data[i]
j = i - 1
while j >= 0 and data[j] > v:
data[j + 1] = data[j]
j -= 1
data[j + 1] = v
print(' '.join([str(n) for n in data])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,624 |
s269459275 | p02255 | u930806831 | 1464082047 | Python | Python3 | py | Accepted | 30 | 7696 | 569 | n = int(input())
input_list = [int(x) for x in input().split()]
def sort_print(n, input_list):
# index[0]~ [n-1]?????§?¨??????????
# ???????????????index??\???????????\?????°???????????°?????\????????????print???
for i in range(n):
index = i
num = input_list[index]
while index-1 >=... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,625 |
s672162213 | p02255 | u647766105 | 1464167536 | Python | Python3 | py | Accepted | 30 | 8140 | 489 | def insert(array, index):
value = array[index]
for i in range(index - 1, -1, -1):
if array[i] < value:
array[i+1] = value
break
array[i + 1] = array[i]
else:
array[0] = value
def insertion_sort(array, log=False):
for i in range(len(array)):
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
| 30,626 |
s409758385 | p02255 | u603356762 | 1464698589 | Python | Python3 | py | Accepted | 30 | 8040 | 206 | n = int(input())
l = [int(x) for x in input().split()]
for i in range(n):
a = l[i]
j = i - 1
while j >= 0 and l[j] > a:
l[j+1] = l[j]
j = j - 1
l[j+1] = a
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
| 30,627 |
s828221361 | p02255 | u603356762 | 1464699858 | Python | Python3 | py | Accepted | 40 | 8088 | 191 | N = int(input())
a = [int(x) for x in input().split()]
for i in range(N):
v = a[i]
j = i-1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j-=1
a[j+1]=v
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
| 30,628 |
s467277189 | p02255 | u121040546 | 1464740919 | Python | Python | py | Accepted | 10 | 6340 | 261 | #coding: utf-8
#ALDS1_1A
import sys
n=int(raw_input())
a=map(int,raw_input().split())
for i in xrange(n):
print a[i],
print
for i in xrange(1,n):
v=a[i]
j=i-1
while j>=0 and a[j]>v:
a[j+1]=a[j]
j-=1
a[j+1]=v
for k in xrange(n):
print a[k],
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
| 30,629 |
s326033824 | p02255 | u569960318 | 1464845500 | Python | Python3 | py | Accepted | 20 | 8108 | 388 | def insertion_sort(A):
for i in range(1,len(A)):
print(*A)
key = A[i]
#/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j-=1
A[j+1] = key
if __name__=='__main__':
n=int(input())
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,630 |
s475449946 | p02255 | u858901574 | 1465050534 | Python | Python | py | Accepted | 10 | 6424 | 380 | import sys
import math
n = input()
a = map(int, raw_input().split())
for i in xrange(n) :
tmp = a[i]
a.pop(i)
for j in xrange(i) :
if a[j] > tmp :
a.insert(j, tmp)
break
else :
a.insert(i, tmp)
for j in xrange(n) :
sys.stdout.write(str(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
| 30,631 |
s837888778 | p02255 | u670498238 | 1465524802 | Python | Python3 | py | Accepted | 30 | 8240 | 244 | import string
n = int(input())
l = []
l = list(map(int, input().split()))
for i in range(n):
key = l[i]
j = i -1
while j >= 0 and l[j] > key:
l[j + 1] = l[j]
j -= 1
l[j + 1] = key
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,632 |
s584018364 | p02255 | u181187284 | 1465786548 | Python | Python3 | py | Accepted | 40 | 7576 | 313 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A
num = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str,A))))
for i in list(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(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
| 30,633 |
s896652233 | p02255 | u203261375 | 1466223169 | Python | Python3 | py | Accepted | 30 | 8084 | 348 | n = int(input())
arr = []
s = input().split()
for i in range(n):
arr.append(int(s[i]))
for i in range(n):
k = arr[i]
j = i - 1
while j >= 0 and arr[j] > k:
arr[j+1] = arr[j]
j -= 1
arr[j+1] = k
for i in range(n):
if i == n-1:
print(arr[i])
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
| 30,634 |
s636659024 | p02255 | u600065151 | 1466596171 | Python | Python | py | Accepted | 10 | 6356 | 213 | N = input()
A = map(int, raw_input().split())
for i in range(len(A)):
v = A[i]
j = i - 1
while (j >= 0) & (A[j] > v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print ' '.join(map(str, A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,635 |
s089675783 | p02255 | u728700495 | 1466750290 | Python | Python3 | py | Accepted | 30 | 7668 | 236 | n = int(input())
data = list(map(int, input().split()))
for i in range(n):
v = data[i]
j = i - 1
while j >= 0 and data[j] > v:
data[j+1] = data[j]
j -= 1
data[j+1] = v
print(" ".join(map(str, data))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,636 |
s812165064 | p02255 | u427088273 | 1466755478 | Python | Python3 | py | Accepted | 20 | 7988 | 254 | num = int(input())
sort_list = list(map(int,input().split()))
print(*sort_list)
v = 0
for i in range(1,num):
v = sort_list[i]
j = i - 1
while j >= 0 and sort_list[j] > v:
sort_list[j+1] = sort_list[j]
j -= 1
sort_list[j+1] = v
print(*sort_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
| 30,637 |
s939857057 | p02255 | u269653912 | 1466838622 | Python | Python | py | Accepted | 10 | 6376 | 224 | N = input()
A = map(int, raw_input().split())
print " ".join(map(str,A))
for i in range(1,N):
v = A[i]
j=i-1
while (j>=0) & (A[j]>v):
A[j+1]=A[j]
j -= 1
A[j+1]=v
print " ".join(map(str,A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,638 |
s441672674 | p02255 | u617990214 | 1467297917 | Python | Python3 | py | Accepted | 30 | 8076 | 263 | def ins(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 k in range(len(A)):
if k==len(A)-1:
print(A[k])
else:
print(A[k],end=" ")
N=int(input())
A=list(map(int,input().split(" ")))
ins(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
| 30,639 |
s582624897 | p02255 | u611490888 | 1468251079 | Python | Python | py | Accepted | 10 | 6380 | 410 | #-*- coding: utf-8 -*-
def insertion_sort(A):
print ' '.join(map(str, A))
for i in xrange(1, N, 1):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print ' '.join(map(str, A))
return A
if __name__ == "__mai... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,640 |
s725571709 | p02255 | u496045719 | 1469354547 | Python | Python3 | py | Accepted | 30 | 7748 | 599 | #!/usr/bin/python
import sys
def main():
length = int(input())
elements = list(map(int, input().split()))
print(" ".join(str(i) for i in elements))
sorted_list = [elements[0]]
for i in range(1, length):
element = elements[i]
for j in range(0, len(sorted_list) + 1):
if j == len(sorted_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
| 30,641 |
s643330418 | p02255 | u612243550 | 1469360044 | Python | Python3 | py | Accepted | 30 | 7580 | 272 | n = int(input())
A = input().split(' ')
#for i in range(n):
# A[i] = int(A[i])
print(" ".join(A))
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and int(A[j]) > int(v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,642 |
s513060165 | p02255 | u612243550 | 1469360789 | Python | Python3 | py | Accepted | 40 | 7644 | 270 | n = int(input())
A = input().split(' ')
#for i in range(n):
# A[i] = int(A[i])
print(" ".join(A))
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and int(A[j]) > int(v):
A[j+1] = A[j]
A[j] = v
j -= 1
print(" ".join(A)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,643 |
s927969645 | p02255 | u554198876 | 1469812346 | Python | Python3 | py | Accepted | 40 | 7720 | 303 | N = int(input())
A = [int(i) for i in input().split()]
def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join([str(i) for i in 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
| 30,644 |
s635783146 | p02255 | u626838615 | 1469951350 | Python | Python3 | py | Accepted | 20 | 7712 | 216 | n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
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,645 |
s641873570 | p02255 | u582608581 | 1470396314 | Python | Python3 | py | Accepted | 40 | 8044 | 390 | def Print(numlist):
for t in range(len(numlist)):
print(numlist[t], end = '')
if t != len(numlist) - 1:
print(end = ' ')
print()
n = eval(input())
numlist = [eval(item) for item in input().split()]
Print(numlist)
for i in range(1, n):
tmp = numlist[i]
for j in range(i, -1, -1):
if tmp > numlist[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,646 |
s570952617 | p02255 | u157698110 | 1470646384 | Python | Python3 | py | Accepted | 50 | 7716 | 492 | def insertion_sort(array):
print_array(array)
for i in range(1,len(array)):
key = array[i]
j = i - 1
while j >= 0 and array[j] > key:
array[j+1] = array[j]
j -= 1
array[j+1] = key
print_array(array)
def print_array(array):
print(str(array)[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,647 |
s405443583 | p02255 | u589886885 | 1470829963 | Python | Python3 | py | Accepted | 20 | 7688 | 250 | n = int(input())
a = input()
print(a)
a = [int(x) for x in a.split(' ')]
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(' '.join([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
| 30,648 |
s949790622 | p02255 | u092047183 | 1471575230 | Python | Python3 | py | Accepted | 30 | 7652 | 220 | n = int(input())
A = list(map(int, input().split()))
for i, key in enumerate(A):
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
| 30,649 |
s227897178 | p02255 | u231136358 | 1471772755 | Python | Python3 | py | Accepted | 40 | 7728 | 286 | N = int(input())
A = [int(s) for s in input().split()]
print(' '.join([str(item) for item in 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 = j - 1
A[j+1] = key
print(' '.join([str(item) for item 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
| 30,650 |
s289322600 | p02255 | u798803522 | 1471918860 | Python | Python3 | py | Accepted | 20 | 7680 | 295 | length = int(input())
targ = [int(n) for n in input().split(' ')]
for l in range(length):
for m in range(l):
if targ[l - m] < targ[l - m - 1]:
disp = targ[l-m -1]
targ[l-m-1] = targ[l-m]
targ[l-m] = disp
print(" ".join([str(n) for n in targ])) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,651 |
s474316173 | p02255 | u798803522 | 1471939638 | Python | Python3 | py | Accepted | 30 | 7740 | 407 | length = int(input())
targ = [int(n) for n in input().split(' ')]
for l in range(length):
insert = 0
for m in range(l):
if targ[l] >= targ[l - m - 1]:
insert = l - m
break
aftdisp = targ[l]
for i in range(0,l - insert):
disp = targ[l - i]
targ[l - i] = tar... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,652 |
s614137798 | p02255 | u510829608 | 1472047928 | Python | Python3 | py | Accepted | 30 | 7968 | 192 | N = int(input())
l = list(map(int, input().split()))
for i in range(N):
t = l[i]
j = i-1
while j >= 0 and l[j] > t:
l[j+1], l[j] = l[j], l[j+1]
j -= 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
| 30,653 |
s146034862 | p02255 | u510829608 | 1472047984 | Python | Python3 | py | Accepted | 20 | 8028 | 192 | N = int(input())
l = list(map(int, input().split()))
for i in range(N):
t = l[i]
j = i-1
while j >= 0 and l[j] > t:
l[j+1], l[j] = l[j], l[j+1]
j -= 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
| 30,654 |
s168188685 | p02255 | u390995924 | 1472559359 | Python | Python3 | py | Accepted | 50 | 7736 | 259 | _ = input()
A = [int(a) for a in input().split(" ")]
for i in range(1, len(A)):
print(" ".join([str(a) for a in 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([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
| 30,655 |
s555772911 | p02255 | u908984540 | 1473781088 | Python | Python3 | py | Accepted | 50 | 8532 | 490 | def show_list(num_list):
for i in range(len(num_list)):
print(str(num_list[i]), end="")
if i < len(num_list)-1:
print(" ", end="")
else:
print()
input_num = int(input())
num_list = [int(i) for i in input().split()]
show_list(num_list)
for i in range(1, len(num_list))... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,656 |
s347402887 | p02255 | u890722286 | 1473973202 | Python | Python3 | py | Accepted | 20 | 7768 | 313 | n = int(input())
numbers = list(map(int, input().split()))
print(' '.join(str(x) for x in numbers))
for i in range(1, n):
key = numbers[i]
j = i - 1
while 0 <= j and key < numbers[j]:
numbers[j+1] = numbers[j]
j -= 1
numbers[j+1] = key
print(' '.join(str(x) for x in numbers)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,657 |
s014096359 | p02255 | u058433718 | 1474027017 | Python | Python3 | py | Accepted | 40 | 8432 | 656 | # ?????\?????????????????°??????
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(sys.stdin.readline().strip())
data = [... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,658 |
s491307208 | p02255 | u685815919 | 1474340335 | Python | Python | py | Accepted | 10 | 6476 | 238 | N = int(raw_input())
A = map(int, raw_input().split())
print " ".join(map(str, A))
for i in xrange(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
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,659 |
s740733116 | p02255 | u756595712 | 1474770674 | Python | Python3 | py | Accepted | 30 | 7684 | 444 | def insertionSort(_list, _length):
for i in range(1, _length):
ll = [str(_l) for _l in _list]
print(' '.join(ll))
val = _list[i]
j = i - 1
while j >= 0 and _list[j] > val:
_list[j+1] = _list[j]
j -= 1
_list[j+1] = val
ll = [str(_l) for _l 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
| 30,660 |
s638047194 | p02255 | u756595712 | 1474771153 | Python | Python3 | py | Accepted | 20 | 8084 | 235 | length = int(input())
eles = [int(i) for i in input().split()]
for i in range(length):
val = eles[i]
j = i - 1
while j >= 0 and eles[j] > val:
eles[j+1] = eles[j]
j -= 1
eles[j+1] = val
print(*eles) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,661 |
s189586559 | p02255 | u391228754 | 1476178728 | Python | Python3 | py | Accepted | 30 | 7664 | 279 | n = int(input())
num = list(map(int, input().split()))
print(" ".join(map(str, num)))
for i in range(len(num)-1):
key = num[i+1]
j = i
while j >= 0 and num[j] > key:
num[j+1] = num[j]
j -= 1
num[j+1] = key
print(" ".join(map(str, num))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,662 |
s780016892 | p02255 | u176732165 | 1476281919 | Python | Python | py | Accepted | 10 | 6460 | 329 | def InsertionSort(A , N):
for i in range(1,N):
v = A[i]
j = i -1
while j > -1 and A[j] > v:
A[j+1] = A[j]
j = j -1
A[j+1] = v
print " ".join(map(str, A))
def main():
N = int( raw_input() )
A = map(int, raw_input().split())
print " ".join(map(str, A))
InsertionSort(A, N)
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
| 30,663 |
s370785611 | p02255 | u159356473 | 1476323650 | Python | Python3 | py | Accepted | 20 | 7700 | 411 | #coding:UTF-8
def IS(N,A):
for i in range(int(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
ans=""
for k in range(len(A)):
ans+=str(A[k])+" "
print(ans[:-1])
if __name__=="__main__":
N=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
| 30,664 |
s318477924 | p02255 | u979507074 | 1476373922 | Python | Python | py | Accepted | 10 | 6464 | 352 | n = int(raw_input())
A = map(int, raw_input().split(" "))
def printElem(B):
string = ""
for elem in B:
string += str(elem) + " "
print(string[:len(string)-1])
printElem(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
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,665 |
s606638932 | p02255 | u534156032 | 1476660265 | Python | Python3 | py | Accepted | 20 | 7728 | 372 | def insertionSort(A, N):
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join(map(str, A)))
if __name__ == "__main__":
n = int(input())
a = [int(e) for e 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
| 30,666 |
s820723284 | p02255 | u500396695 | 1476709523 | Python | Python3 | py | Accepted | 20 | 7716 | 295 | N = int(input())
A = [int(i) for i in input().split()]
print(' '.join([str(A[i]) for i in range(0, N)]))
for i in range(1, N):
v = int(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[i]) for i in range(0, 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
| 30,667 |
s979635887 | p02255 | u831244171 | 1477667981 | Python | Python | py | Accepted | 10 | 6440 | 261 | N = input()
n = list(map(int,raw_input().split()))
print(" ".join(list(map(str,n))))
for i in range(1,int(N)):
v = n[i]
j = i - 1
while j >= 0 and v < n[j]:
n[j+1] = n[j]
j = j - 1
n[j+1] = v
print(" ".join(list(map(str,n)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,668 |
s049806596 | p02255 | u996758922 | 1477810530 | Python | Python3 | py | Accepted | 50 | 8060 | 267 | 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 i in range(n-1):
print(str(a[i]) + " ", end="")
print(a[n-1]) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,669 |
s883736572 | p02255 | u175111751 | 1477814878 | Python | Python3 | py | Accepted | 20 | 8048 | 195 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,670 |
s285227693 | p02255 | u022407960 | 1477843011 | Python | Python | py | Accepted | 20 | 6420 | 373 | num = int(raw_input())
line = raw_input()
item_str = line.strip().split(" ")
print " ".join(item_str)
A = map(int, item_str)
for i in range(1, num):
v = A[i]
j = i - 1
for j in range(j, -1, -1):
if A[j] > v:
A[j+1] = A[j]
j -= 1
else:
break
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
| 30,671 |
s029850861 | p02255 | u022407960 | 1477844248 | Python | Python3 | py | Accepted | 50 | 7688 | 217 | n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
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,672 |
s372692622 | p02255 | u022407960 | 1477844344 | Python | Python3 | py | Accepted | 50 | 7704 | 758 | #!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
class Solution:
"""
@param prices: Given an integer array
@return: Maximum profit
"""
@staticmethod
def insertion_sort():
# write your code here
array_length = int(input())
unsorted_array = ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,673 |
s579508763 | p02255 | u022407960 | 1477844619 | Python | Python3 | py | Accepted | 20 | 7656 | 758 | #!/usr/bin/env python
# encoding: utf-8
from __future__ import print_function
class Solution:
"""
@param prices: Given an integer array
@return: Maximum profit
"""
@staticmethod
def insertion_sort():
# write your code here
array_length = int(input())
unsorted_array = ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,674 |
s894559581 | p02255 | u451769769 | 1478265929 | Python | Python | py | Accepted | 10 | 6448 | 280 | #!/usr/bin/env python
N = raw_input()
A =raw_input().split()
print ' '.join(map(str, A))
A = map(int, 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 = 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,675 |
s993596724 | p02255 | u554572515 | 1478486470 | Python | Python | py | Accepted | 20 | 6368 | 420 | def insertionSort(length, numbers):
for i in range(length):
for k in range(length):
if numbers[i] <= numbers[k]:
numbers.insert(k, numbers[i])
del numbers[i+1]
print ' '.join(map(str, numbers))
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
| 30,676 |
s286230665 | p02255 | u534156032 | 1478581470 | Python | Python3 | py | Accepted | 50 | 7720 | 217 | 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(" ".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,677 |
s826559731 | p02255 | u922871577 | 1478933876 | Python | Python | py | Accepted | 10 | 6440 | 246 | N = input()
A = map(int, raw_input().split())
print ' '.join(map(str, A))
for i in xrange(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,678 |
s100566754 | p02255 | u082526811 | 1479006883 | Python | Python3 | py | Accepted | 30 | 7696 | 266 | n = int(input())
a = list(map(int, input().split()))
for i in range(1, n):
print(' '.join(list(map(str, a))))
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(' '.join(list(map(str, a)))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,679 |
s048507332 | p02255 | u428229577 | 1479171048 | Python | Python3 | py | Accepted | 20 | 8016 | 180 | 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
| 30,680 |
s759976826 | p02255 | u742013327 | 1479193853 | Python | Python3 | py | Accepted | 20 | 8044 | 883 | #http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp
#?????\????????????????£?
#?¨?????????????????????????????????±?????????
def insertion_sort(target_list, n_list):
for focus_index in range(1, n_list):
print(*target_list)
target = target_list[focus_index]
if tar... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,681 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.