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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s050615102 | p02255 | u546285759 | 1479624777 | Python | Python3 | py | Accepted | 20 | 7652 | 266 | N = int(input())
seq = list(map(int, input().split()))
print(" ".join(map(str, seq)))
for i in range(1, N):
key = seq[i]
j = i-1
while j >= 0 and seq[j] > key:
seq[j+1] = seq[j]
j -= 1
seq[j+1] = key
print(" ".join(map(str, seq))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,682 |
s557484217 | p02255 | u086566114 | 1479874634 | Python | Python | py | Accepted | 10 | 6352 | 438 | """
implementation of the Insertion Sort
"""
number_of_input = int(raw_input())
numbers = [int(x) for x in raw_input().split()]
for i in range(1, len(numbers)):
print " ".join([str(x) for x in numbers])
target = numbers[i]
index = i - 1
while index >= 0 and target < numbers[index]:
numbers[ind... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,683 |
s553242301 | p02255 | u086566114 | 1479874701 | Python | Python | py | Accepted | 10 | 6428 | 438 | """
implementation of the Insertion Sort
"""
number_of_input = int(raw_input())
numbers = [int(x) for x in raw_input().split()]
for i in range(1, len(numbers)):
print " ".join([str(x) for x in numbers])
target = numbers[i]
index = i - 1
while index >= 0 and target < numbers[index]:
numbers[ind... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,684 |
s829713070 | p02255 | u086566114 | 1479874790 | Python | Python | py | Accepted | 10 | 6424 | 439 | """
implementation of the Insertion Sort
"""
number_of_input = int(raw_input())
numbers = [int(x) for x in raw_input().split()]
print " ".join([str(x) for x in numbers])
for i in range(1, number_of_input):
target = numbers[i]
index = i - 1
while index >= 0 and target < numbers[index]:
numbers[index... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,685 |
s060589135 | p02255 | u195186080 | 1480086270 | Python | Python3 | py | Accepted | 30 | 7984 | 200 | n = int(input())
l = list(map(int,input().split()))
print(*l)
for i in range(1,n):
v = l[i]
j = i-1
while j>=0 and l[j]>v:
l[j+1] = l[j]
j -= 1
l[j+1] = v
print(*l) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,686 |
s546275864 | p02255 | u660912567 | 1480192546 | Python | Python3 | py | Accepted | 30 | 7980 | 224 | n = int(input())
line = list(map(int,input().split()))
print(*line)
for i in range(1,n):
v = line[i]
j = i-1
while j>=0 and line[j]>v:
line[j+1] = line[j]
j -= 1
line[j+1] = v
print(*line) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,687 |
s317544504 | p02255 | u497195381 | 1480240136 | Python | Python | py | Accepted | 10 | 6348 | 236 | N=input()
A=map(int,raw_input().split())
for i in range(N-1):
for k in range(N-1):
print A[k],
print A[N-1]
v=A[i+1]
j=i
while j>=0 and A[j] >v:
A[j+1]=A[j]
j=j-1
A[j+1]=v
for m in range(N-1):
print str(A[m]),
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,688 |
s276570258 | p02255 | u497195381 | 1480240165 | Python | Python | py | Accepted | 10 | 6416 | 236 | N=input()
A=map(int,raw_input().split())
for i in range(N-1):
for k in range(N-1):
print A[k],
print A[N-1]
v=A[i+1]
j=i
while j>=0 and A[j] >v:
A[j+1]=A[j]
j=j-1
A[j+1]=v
for m in range(N-1):
print str(A[m]),
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,689 |
s946319927 | p02255 | u119456964 | 1480253205 | Python | Python | py | Accepted | 30 | 6420 | 335 | def insertionSort(A):
print " ".join(map(str, A))
for i in range(1, len(A)):
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))
N = int(raw_input())
A = map(int, raw_input().split())
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,690 |
s772048951 | p02255 | u811733736 | 1480425260 | Python | Python3 | py | Accepted | 20 | 7716 | 1,098 | def insertion_sort(array, debug=False):
""" AOJ??¬??¶?????¬???
http://judge.u-aizu.ac.jp/onlinejudge/commentary.jsp?id=ALDS1_1_A
:param array: ?????????????±??????????
:param debug: ??????????????????????????????????????????????????°
:return: ?????????????????????
"""
for i in range(0, len(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,691 |
s330391781 | p02255 | u089830331 | 1480441210 | Python | Python3 | py | Accepted | 20 | 7688 | 325 | def insertion_sort(arr):
print(" ".join(map(str, arr)))
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >= 0 and arr[j] > key:
arr[j + 1] = arr[j]
j -= 1
arr[j + 1] = key
print(" ".join(map(str, arr)))
n = int(input())
arr = list(map(int, input().split()))
insertion_sort... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,692 |
s047050455 | p02255 | u186082958 | 1480489502 | Python | Python3 | py | Accepted | 40 | 8136 | 367 | def show (nums):
for i in range(len(nums)):
if i!=len(nums)-1:
print(nums[i],end=' ')
else :
print(nums[i])
n=int(input())
nums=list(map(int,input().split()))
show(nums)
for i in range(1,n):
v=nums[i]
j=i-1
while (j>=0 and nums[j]>v):
nums[j+1]=nums[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,693 |
s008289160 | p02255 | u611490888 | 1480595335 | Python | Python3 | py | Accepted | 20 | 7672 | 512 | #! /usr/bin/env python
#-*- coding: utf-8 -*-
''' ?????\????????? '''
#
# ?¨??????????O()
def insertion_sort(A, N):
for i in range(N):
tmp = A[i]
j = i - 1
while j >= 0 and A[j] > tmp:
A[j + 1] = A[j]
j -= 1
A[j + 1] = tmp
print(' '.join(map(str... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,694 |
s149404335 | p02255 | u209358977 | 1480956241 | Python | Python3 | py | Accepted | 30 | 7720 | 371 | # -*- coding: utf-8 -*-
def insertion_sort(a, n):
for i in range(n):
tmp = a[i]
j = i - 1
while j >= 0 and a[j] > tmp:
a[j + 1] = a[j]
j -= 1
a[j + 1] = tmp
print(' '.join(map(str, a)))
if __name__ == '__main__':
n = int(input())
a = [int(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,695 |
s810565012 | p02255 | u908984540 | 1481554241 | Python | Python3 | py | Accepted | 30 | 8016 | 527 | # -*- coding : utf-8 -*-
def insertion_sort(list):
for i in range(1, len(list)):
key = list[i]
j = i - 1
show_list(list)
while(j >= 0 and list[j] > key):
list[j+1] = list[j]
j = j - 1
list[j+1] = key
show_list(list)
return list
def show_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,696 |
s376139967 | p02255 | u941958472 | 1482076529 | Python | Python3 | py | Accepted | 20 | 7688 | 372 | def insertion_sort(seq):
print(' '.join(map(str, seq)))
for i in range(1, len(seq)):
key = seq[i]
j = i - 1
while j >= 0 and seq[j] > key:
seq[j+1] = seq[j]
j -= 1
seq[j+1] = key
print(' '.join(map(str, seq)))
return seq
n = int(input())
seq =... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,697 |
s863154913 | p02255 | u929986002 | 1482079015 | Python | Python3 | py | Accepted | 30 | 7668 | 381 | N = int(input())
#print(N)
card = list(map(int, input().split()))
#print(card)
for i in range(N):
v = card[i]
j = i - 1
while j >= 0 and card[j] > v:
card[j+1] = card[j]
j = j -1
card[j+1] = v
#print(card)
card_str = ""
for k in range(N):
card_str += str(card[k]... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,698 |
s665886881 | p02255 | u923668099 | 1482123664 | Python | Python3 | py | Accepted | 30 | 8084 | 235 | # coding: utf-8
n = int(input())
data = [int(i) for i in 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(*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,699 |
s632566186 | p02255 | u770513705 | 1482927273 | Python | Python3 | py | Accepted | 30 | 7684 | 445 |
def insertion_sort(a, n):
for i in range(0, 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
# convert string to int.
process_list = map(str, a)
# join as string.
print(" ".join(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,700 |
s935889426 | p02255 | u475480520 | 1483535480 | Python | Python | py | Accepted | 10 | 6440 | 387 | #input number
n = raw_input()
if n < 1 and n > 100:
exit()
# input elements
l = raw_input()
elements = [int(e) for e in l.split()]
print ' '.join(str(e) for e in elements)
for i in range(1, int(n)):
key = elements[i]
j = i - 1
while j >= 0 and elements[j] > key:
elements[j + 1] = elements[j]
j -= 1
elemen... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,701 |
s493399684 | p02255 | u935329231 | 1483623019 | Python | Python3 | py | Accepted | 20 | 7748 | 532 | # -*- coding: utf-8 -*-
def insertion_sort(seq, l):
print(' '.join([str(n) for n in seq]))
for i, v in enumerate(seq[1:], start=1):
left = i - 1
while left >= 0 and seq[left] > v:
seq[left], seq[left+1] = seq[left+1], seq[left]
left -= 1
print(' '.join([str(n) 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
| 30,702 |
s208308290 | p02255 | u370086573 | 1483775169 | Python | Python3 | py | Accepted | 30 | 8116 | 328 | # ??\?????????
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_so... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,703 |
s502621204 | p02255 | u547492399 | 1483955385 | Python | Python3 | py | Accepted | 30 | 8116 | 317 | debug = True
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
if debug: print(*A)
n = int(input())
arr = list(map(int, input().split()))
print(*arr)
insertionSort(arr, n) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,704 |
s264759366 | p02255 | u711765449 | 1483976526 | Python | Python3 | py | Accepted | 30 | 8064 | 480 | # -*- coding:utf-8 -*-
import sys
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
return A
n = int(input())
A = input()
A = A.split()
A = [int(i) for i in A]
for i in range(1,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,705 |
s444530804 | p02255 | u923668099 | 1484217240 | Python | Python3 | py | Accepted | 20 | 8100 | 303 |
def InsertionSort(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]
j -= 1
A[j + 1] = v
print(*A)
N = int(input())
A = [int(a) for a in input().split()]
InsertionSort(A, N) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,706 |
s409407392 | p02255 | u432957752 | 1484272898 | Python | Python3 | py | Accepted | 30 | 7744 | 298 | def insertion(A,n):
for i in range(0,n):
tmp = A[i]
j = i - 1
while(A[j] > tmp and j >= 0):
A[j+1] = A[j]
j-=1
A[j+1] = tmp
printList(A)
def printList(A):
print(" ".join(str(x) for x in A))
n = int(input())
A = [int(x) for x in input().split()]
insertion(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,707 |
s725382810 | p02255 | u867503285 | 1484321794 | Python | Python3 | py | Accepted | 30 | 7740 | 453 | def insertion_sort(target_list):
sorted_list = list()
for target in target_list[:]:
for i, num in enumerate(sorted_list):
if num > target:
sorted_list[i:i] = [target]
break
else:
sorted_list.append(target)
target_list.pop(0)
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,708 |
s048609048 | p02255 | u303093818 | 1484413837 | Python | Python3 | py | Accepted | 30 | 8164 | 394 | def insert_sort(A):
for i in range(1, len(A)):
k = A[i]
j = i - 1
while j >= 0 and A[j] > k:
A[j + 1] = A[j]
j -= 1
A[j + 1] = k
show(A)
def show(A):
for i in range(len(A) - 1):
print(A[i], end=" ")
print(A[len(A) - 1])
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,709 |
s127703459 | p02255 | u918276501 | 1484594907 | Python | Python3 | py | Accepted | 30 | 8104 | 204 | n = int(input())
lst = list(map(int, input().split()))
for i in range(n):
li = lst[i]
j = i-1
while j >= 0 and lst[j] > li:
lst[j:j+2] = lst[j+1], lst[j]
j -= 1
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
| 30,710 |
s103015541 | p02255 | u620998209 | 1484800714 | Python | Python3 | py | Accepted | 30 | 7772 | 594 | def main():
N = int(input())
values = list(map(int,input().split()))
for i in range(1,N):
print(" ".join(map(str,values)))
v = values[i]
j = i - 1
while 0 <= j and v < values[j]:
values[j+1] = values[j]
j -= 1
values[j+1] = v
print(" ".join... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,711 |
s379702375 | p02255 | u656153606 | 1485044140 | Python | Python3 | py | Accepted | 40 | 8088 | 312 | n = int(input())
arrey = [int(i) for i in input().split()]
for i in range(n):
v = arrey[i]
j = i - 1
while j >= 0 and arrey[j] > v:
arrey[j+1] = arrey[j]
j = j - 1
arrey[j+1] = v
for k in range(n):
print(arrey[k]) if k == n-1 else print(str(arrey[k])+' ',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,712 |
s376649947 | p02255 | u162598098 | 1485093711 | Python | Python3 | py | Accepted | 30 | 8000 | 348 | def insertionSort(lis,leng):
for i in range(leng):
v = lis[i]
j = i - 1
while j >= 0 and lis[j] > v:
lis[j+1] = lis[j]
j = j-1
lis[j+1]=v
print(*lis)
if __name__ == "__main__":
lengg=int(input())
liss=list(map(int, input().split()))
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,713 |
s267172268 | p02255 | u600065151 | 1485501362 | Python | Python3 | py | Accepted | 20 | 8172 | 324 | def insertionSort():
N = int(input())
lst = list(map(int, input().split()))
for i in range(1, N):
print(*lst)
v = lst[i]
j = i - 1
while j >= 0 and lst[j] > v:
lst[j+1] = lst[j]
j -= 1
lst[j+1] = v
print(*lst)
insertionSo... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,714 |
s289578564 | p02255 | u771917453 | 1485580282 | Python | Python | py | Accepted | 10 | 6460 | 198 | n = input()
a = map(int,raw_input().split())
for i in xrange(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,715 |
s731887331 | p02255 | u771917453 | 1485594756 | Python | Python | py | Accepted | 10 | 6468 | 228 | 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 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,716 |
s707953508 | p02255 | u519227872 | 1486388743 | Python | Python3 | py | Accepted | 20 | 7760 | 324 | def insertionSort(A,N):
print (" ".join(map(str,A)))
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print (" ".join(map(str,A)))
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
| 30,717 |
s535183271 | p02255 | u144068724 | 1487081965 | Python | Python3 | py | Accepted | 20 | 7620 | 218 | n = int(input())
A = list(map(int,input().split()))
for i in range(len(A)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
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,718 |
s964303924 | p02255 | u831244171 | 1487144141 | Python | Python3 | py | Accepted | 30 | 7644 | 212 | n = int(input())
a = list(map(int,input().split()))
for i in range(len(a)):
for j in range(i):
if a[i] < a[j]:
a.insert(j,a.pop(i))
break
print(" ".join(map(str,a)),)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,719 |
s082102608 | p02255 | u548155360 | 1487384128 | Python | Python3 | py | Accepted | 20 | 7672 | 218 | 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,720 |
s335177997 | p02255 | u895660619 | 1487468820 | Python | Python3 | py | Accepted | 30 | 7744 | 270 |
N = int(input())
A = [int(a) for a in 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,721 |
s481125787 | p02255 | u109778250 | 1487678047 | Python | Python3 | py | Accepted | 20 | 7664 | 237 | #coding: UTF-8
N=int(input())
L=list(map(int,input().split()))
print(' '.join(map(str,L)))
for i in range(1,N):
v=L[i]
j=i-1
while j>=0 and L[j]>v:
L[j+1]=L[j]
j-=1
L[j+1]=v
print(' '.join(map(str,L))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,722 |
s714163071 | p02255 | u370086573 | 1487678311 | Python | Python3 | py | Accepted | 30 | 8044 | 334 | def insertionSort(n, A):
for i in range(n):
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)
return A
if __name__ == '__main__':
N = int(input())
A = list(map(int, input().split()))
inser... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,723 |
s247816578 | p02255 | u283315132 | 1487767024 | Python | Python3 | py | Accepted | 20 | 7748 | 279 | def rren(): return list(map(int, input().split()))
N = int(input())
R = rren()
print(" ".join(map(str, R)))
for i in range(1,N):
take = R[i]
j = i-1
while j >= 0 and R[j] > take:
R[j+1] = R[j]
j -= 1
R[j+1] = take
print(" ".join(map(str, 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
| 30,724 |
s913035679 | p02255 | u227438830 | 1487954692 | Python | Python3 | py | Accepted | 20 | 7748 | 261 | N = int(input())
A = [int(i) for i in input().split()]
for i in range(1, N):
print(" ".join(map(str, A)))
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(map(str, A))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,725 |
s386508254 | p02255 | u627348629 | 1488123733 | Python | Python3 | py | Accepted | 30 | 8040 | 442 | n = int(input())
sequence = input().split(' ')
sequence = [int(x) for x in sequence]
for h in range(n - 1):
print(format(sequence[h]) + ' ', end='')
print(sequence[n - 1])
for i in range(1, n):
v = sequence[i]
j = i - 1
while j >= 0 and sequence[j] > v:
sequence[j+1] = sequence[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,726 |
s202584593 | p02255 | u301461168 | 1488561337 | Python | Python3 | py | Accepted | 20 | 7668 | 317 | num_cnt = int(input().rstrip())
nums = list(map(int, input().rstrip().split(" ")))
for i in range(num_cnt):
tmpNum = nums[i]
j = i -1
while j >=0:
if nums[j] <= tmpNum:
break
nums[j+1] = nums[j]
j = j-1
nums[j+1] = tmpNum
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
| 30,727 |
s070950709 | p02255 | u004192101 | 1488986532 | Python | Python3 | py | Accepted | 40 | 8392 | 361 | n = input()
A = [int(i) for i in input().split(' ')]
def trace(A):
for index, v in enumerate(A):
print(v, end='')
if index != len(A) - 1:
print(' ', end='')
print()
trace(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]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,728 |
s808644653 | p02255 | u004192101 | 1488986977 | Python | Python3 | py | Accepted | 40 | 8452 | 636 | n = input()
A = [int(i) for i in input().split(' ')]
def trace(A):
for index, v in enumerate(A):
print(v, end='')
if index != len(A) - 1:
print(' ', end='')
print()
trace(A)
# algorithm
# for i in range(1, len(A)):
# v = A[i]
# j = i - 1
# while j >= 0 and A[j] > 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,729 |
s217829817 | p02255 | u825178626 | 1489139457 | Python | Python3 | py | Accepted | 20 | 7604 | 300 | def sort(l):
for i in range(len(l)) :
key = l[i]
j = i-1
while j>=0 and l[j]>key:
l[j+1] = l[j]
j -= 1
l[j+1] = key
print(" ".join(map(str,l)))
n = int(input())
line = list(map(int,input().split(" ")))
sort(line) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,730 |
s625988543 | p02255 | u197615397 | 1489232106 | Python | Python3 | py | Accepted | 20 | 7676 | 353 | def insertionSort(a):
print(" ".join([str(i) for i in a]))
n = len(a)
for i in range(1, n):
v = a[i]
j = i-1
while j>=0 and a[j]>v:
a[j+1] = a[j]
j-=1
a[j+1] = v
print(" ".join([str(i) for i in a]))
n = input()
a = [int(s) for s in inp... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,731 |
s041837435 | p02255 | u130834228 | 1489302628 | Python | Python3 | py | Accepted | 20 | 8000 | 224 | N = int(input())
A = [int(x) for x in input().split()]
print(*A)
for i in range(1, len(A)):
key = A[i]
j = i-1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j += -1
A[j+1] = key
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,732 |
s211543118 | p02255 | u939814144 | 1489375853 | Python | Python3 | py | Accepted | 60 | 8032 | 642 | def insertion_sort(array, element_number):
for i in range(element_number):
v = array[i]
j = i - 1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j = j - 1
array[j+1] = v
for k in range(element_number):
if k < element_number-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,733 |
s229067280 | p02255 | u939814144 | 1489577374 | Python | Python3 | py | Accepted | 20 | 7672 | 1,006 | def insertion_sort(array):
'''?????????????´?????????????????????¨??????????????????????????¨???????????????????????§?????\?????????????????°????????????
1. ??????????????¨??????????????????????´?????????????????????? v ????¨?????????????
2. ????????????????????¨??????????????????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,734 |
s847216740 | p02255 | u825178626 | 1489725008 | Python | Python3 | py | Accepted | 20 | 7752 | 304 | def inSort(n):
print(" ".join(list(map(str,n))))
for i in range(1,len(n)):
v = n[i]
j = i-1
while j>=0 and n[j]>v:
n[j+1]=n[j]
j-=1
n[j+1]=v
print(" ".join(list(map(str,n))))
A=input()
N=list(map(int,input().split()))
inSort(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,735 |
s203910636 | p02255 | u351208175 | 1489977861 | Python | Python3 | py | Accepted | 30 | 7660 | 299 | def insertionSort(a,n):
for i in range(n):
v = a[i]
j = i-1
while j>=0 and a[j]>v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(" ".join(map(str,a)))
return a
n = int(input())
a = [int(i) for i in input().split()]
insertionSort(a,n) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,736 |
s276575813 | p02255 | u804019169 | 1490033664 | Python | Python3 | py | Accepted | 20 | 7756 | 552 | import sys
def print_arr(arr):
ln = ''
for v in arr:
ln += str(v) + ' '
ln = ln.strip()
print(ln)
def insertion_sort(arr):
for i in range(1, len(arr)):
print_arr(arr)
v = arr[i]
j = i-1
while j >= 0 and arr[j] > v:
arr[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
| 30,737 |
s917748249 | p02255 | u780342333 | 1490090568 | Python | Python3 | py | Accepted | 30 | 7720 | 267 | N = int(input())
A = [int (x) for x in input().split(" ")]
for i in range(1, N):
print(" ".join([str(x) for x in A]))
v = A[i]
j = i -1
while j>=0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join([str(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,738 |
s532397461 | p02255 | u868716420 | 1490821293 | Python | Python3 | py | Accepted | 30 | 7748 | 250 | tim = int(input())
A = [int(A) for A in input().split()]
for i in range(tim) :
v = A[i]
j = i - 1
while j >= 0 and A[j] > v :
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
A2 = list(map(str, A))
print(' '.join(A2)) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,739 |
s693264066 | p02255 | u923668099 | 1490841295 | Python | Python3 | py | Accepted | 20 | 8048 | 442 | def solve():
N = int(input())
A = [int(i) for i in input().split()]
InsertionSort(N, A)
def InsertionSort(N, A):
print(*A)
for i in range(1, N):
v = A[i]
for j in range(i - 1, -1, -1):
if A[j] > v:
A[j + 1] = A[j]
else:
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,740 |
s401600799 | p02255 | u462831976 | 1491038288 | Python | Python3 | py | Accepted | 20 | 8072 | 381 | # -*- coding: utf-8 -*-
import sys
import os
def insertion_sort(A):
n = len(A)
for i in range(1, n):
v = A[i]
j = i - 1
# i-1????????§???sort??????
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
input()
lst = 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
| 30,741 |
s634391109 | p02255 | u873302699 | 1491302043 | Python | Python | py | Accepted | 10 | 6272 | 519 | def get_input():
length = int(raw_input())
return map(int, raw_input().split())
def insertionSort(input_array):
print " ".join(str(each) for each in input_array).rstrip(" ")
for i in range(1,len(input_array)):
key = input_array[i]
j = i-1
while j >= 0 and input_array[j] > 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
| 30,742 |
s360743786 | p02255 | u395334793 | 1491823838 | Python | Python3 | py | Accepted | 20 | 7868 | 218 | n = int(input())
A = list(map(int,input().split()))
for i in range(1,len(A)):
print(*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(*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,743 |
s336868127 | p02255 | u024715419 | 1492156757 | Python | Python3 | py | Accepted | 20 | 7508 | 212 | 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
| 30,744 |
s192194009 | p02255 | u208157605 | 1492464192 | Python | Python3 | py | Accepted | 20 | 7580 | 424 | n = int(input())
A = list(map(int, input().split()))
result_list = []
result_list.append(A[:])
for i in range(1,len(A)):
key = A[i]
j = i -1
while j >= 0 and A[j] > key:
A[j+1] = A[j]
j -= 1
A[j+1] = key
result_list.append(A[:])
for i in range(n):
if i > len(result_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,745 |
s241480392 | p02255 | u046107993 | 1492492475 | Python | Python3 | py | Accepted | 30 | 7752 | 456 | #!/usr/bin/env python
size = int(input())
line = list(map(int, input().split()))
def insertionSort(A, N):
ans = " ".join(map(str, line))
print(ans)
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,746 |
s707963956 | p02255 | u810591206 | 1492782892 | Python | Python3 | py | Accepted | 30 | 8024 | 290 | def isort(seq, n):
for i in range(1, n):
x = seq[i]
j = i - 1
while j >= 0 and seq[j] > x:
seq[j + 1] = seq[j]
j -= 1
seq[j + 1] = x
print(*seq)
n = int(input())
x = list(map(int, input().split()))
print(*x)
isort(x, 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,747 |
s050394579 | p02255 | u796784914 | 1492843303 | Python | Python | py | Accepted | 10 | 6416 | 287 | N = input()
A = map(int,raw_input().split())
for i in range(N-1):
print A[i],
print A[-1]
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
for i in range(N-1):
print A[i],
print A[-1] | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,748 |
s051573394 | p02255 | u286589639 | 1493084504 | Python | Python3 | py | Accepted | 30 | 7952 | 316 | N = int(input())
A = list(map(int, input().split()))
for k in range(N-1):
print(A[k], end=" ")
print(A[N-1])
for i in range(1, N):
v = A[i]
j = i - 1
while(j>=0 and A[j] > v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
for k in range(N-1):
print(A[k], end=" ")
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,749 |
s280184181 | p02255 | u843404779 | 1493205955 | Python | Python3 | py | Accepted | 20 | 7672 | 482 | def print_list(ele_list):
print(" ".join(map(str, ele_list)))
def insertion_sort(ele_list):
len_ele_list = len(ele_list)
print_list(ele_list)
for i in range(1, len_ele_list):
key = ele_list[i]
j = i - 1
while j >= 0 and ele_list[j] > key:
ele_list[j+1] = ele_list[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,750 |
s944767807 | p02255 | u297744593 | 1493446194 | Python | Python3 | py | Accepted | 20 | 7640 | 331 | # 3.2
# input
N = int(input())
#a = [(input()) for i in range(N)]
a = list(map(int, input().split())) # "1 2 3"??¨??\???
print(" ".join(map(str, a)))
for i in range(1, N):
tmp = a[i]
j = i - 1
while j >= 0 and a[j] > tmp:
a[j + 1] = a[j]
j -= 1
a[j + 1] = tmp
print(" ".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,751 |
s178834024 | p02255 | u782850499 | 1493474616 | Python | Python3 | py | Accepted | 20 | 7568 | 306 | size = int(input())
element = list(map(int,input().split()))
print(" ".join(map(str,element)))
for i in range(1,len(element)):
v = element[i]
j = i-1
while j >=0 and element[j] > v:
element[j+1] = element[j]
j -=1
element[j+1] = v
print(" ".join(map(str,element))) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,752 |
s847300194 | p02255 | u000317780 | 1493553193 | Python | Python3 | py | Accepted | 20 | 7704 | 392 | # coding: utf-8
def printls(ls):
print(' '.join(map(str,ls)))
def main():
trash = input()
ls = list(map(int, input().split(' ')))
for i in range(1, len(ls)):
printls(ls)
v = ls[i]
for j in reversed(range(0, i)):
if ls[j] > v:
ls[j], ls[j+1] = ls... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,753 |
s111086278 | p02255 | u591232952 | 1493617075 | Python | Python3 | py | Accepted | 20 | 7636 | 273 | def insertionSort(A,N):
for i,v in enumerate(A):
j = i-1
while j>=0 and A[j] > v:
A[j+1] = A[j]
j-=1
A[j+1] = v
print(' '.join(map(str, A)))
N = int(input())
A = list(map(int, input().split()))
insertionSort(A,N) | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,754 |
s486507211 | p02255 | u625806423 | 1493826122 | Python | Python3 | py | Accepted | 20 | 7700 | 233 | N = int(input())
a = [int(i) for i in 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
| 30,755 |
s098185425 | p02255 | u352522848 | 1494759556 | Python | Python | py | Accepted | 10 | 6384 | 298 | _n = int(raw_input())
_a = [int(x) for x in raw_input().split()]
for i in range(1, _n):
print(" ".join([str(x) for x 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(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,756 |
s366757655 | p02255 | u939814144 | 1494906506 | Python | Python3 | py | Accepted | 20 | 7708 | 421 | def insertion_sort(array):
for i in range(len(array)):
v = array[i]
j = i - 1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j = j - 1
array[j+1] = v
print(' '.join(map(str, array)))
return array
if __name__ == '__main__':
element_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,757 |
s162803925 | p02255 | u827818594 | 1494908960 | Python | Python3 | py | Accepted | 20 | 7640 | 421 | def insertion_sort(array):
for i in range(len(array)):
v = array[i]
j = i - 1
while(j>=0 and array[j] > v):
array[j+1] = array[j]
j = j - 1
array[j+1] = v
print(' '.join(map(str, array)))
return array
if __name__ == '__main__':
element_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,758 |
s613860617 | p02255 | u279605379 | 1495256605 | Python | Python3 | py | Accepted | 30 | 7624 | 406 | #ALDS1_1-A
def print_A(A,N):
stri = ""
for i in range(N-1):
stri+=str(A[i])+" "
stri+=str(A[N-1])
print(stri)
def insertionSort(A,N):
for i in range(N-1):
v=A[i+1]
j=i
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print_A(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,759 |
s344573425 | p02255 | u362104929 | 1495292806 | Python | Python3 | py | Accepted | 20 | 8016 | 320 | def insert_sort():
n = int(input())
A = [int(x) for x in input().split()]
print(*A)
for i in range(1,n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
if __name__ == "__main__":
insert_sort() | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,760 |
s226036821 | p02255 | u905808447 | 1495548494 | Python | Python | py | Accepted | 10 | 6404 | 568 | import sys, re
def echo(A):
for i, a in enumerate(A):
if i < len(A) - 1:
sys.stdout.write('%d ' % a)
else:
sys.stdout.write('%d\n' % a)
def insertionSort(A, N):
echo(A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > 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,761 |
s409999077 | p02255 | u650790815 | 1495689976 | Python | Python3 | py | Accepted | 20 | 7596 | 230 | n = int(input())
lst = list(map(int,input().split()))
for i in range(n):
key = lst[i]
j = i-1
while j >= 0 and lst[j] > key:
lst[j+1] = lst[j]
j -= 1
lst[j+1] = key
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
| 30,762 |
s125784533 | p02255 | u603049633 | 1495800941 | Python | Python3 | py | Accepted | 20 | 7636 | 186 | 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
| 30,763 |
s798363978 | p02255 | u905313459 | 1496138849 | Python | Python3 | py | Accepted | 20 | 7708 | 299 | def insertionsort(x):
x = list(map(int, x))
for i in range(len(x)):
for k in range(i, 0, -1):
if x[k-1] > x[k]:
x[k-1], x[k] = x[k], x[k-1]
print(" ".join(map(str, x)))
if __name__ == "__main__":
input()
insertionsort(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,764 |
s020476450 | p02255 | u256678932 | 1496397933 | Python | Python3 | py | Accepted | 20 | 7740 | 429 | def main():
N = int(input())
A = list(map(int, input().split(' ')))
insertion_sort(A, N)
def insertion_sort(A, N):
print(' '.join([str(n) for n in A]))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,765 |
s868263445 | p02255 | u821624310 | 1496635787 | Python | Python3 | py | Accepted | 40 | 7960 | 453 | N = int(input())
A = list(map(int, input().split()))
for k in range(N):
if k == N - 1:
print(str(A[k]))
else:
print(str(A[k]) + " ", end="")
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j+1] = v
for k in ra... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,766 |
s843838339 | p02255 | u533883485 | 1496723377 | Python | Python3 | py | Accepted | 20 | 7648 | 494 | #coding: utf-8
def print_list(X):
first_frag = True
for val in X:
if first_frag:
print_line = str(val)
first_frag = False
else:
print_line = print_line + ' ' + str(val)
print(print_line)
N = int(input())
A = list(map(int, input().split()))
print_list(A)... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,767 |
s785746517 | p02255 | u591588652 | 1497271166 | Python | Python3 | py | Accepted | 30 | 7960 | 403 | N = int(input())
s = input().split(" ")
A = list(map(int,s))
for i in range(N):
if i == N-1:
print(A[i])
else:
print(A[i],end=" ")
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
for 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,768 |
s326452511 | p02255 | u091533407 | 1497659679 | Python | Python3 | py | Accepted | 30 | 7676 | 403 | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 17 09:19:58 2017
@author: syaga
"""
if __name__ == "__main__":
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... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
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,769 |
s862162009 | p02255 | u662126750 | 1497972090 | Python | Python3 | py | Accepted | 30 | 7976 | 346 | # coding: utf-8
n = int(input())
num = list(map(int, input().split()))
for i in range(n):
tmp = num[i]
j = i
while j>0 and num[j-1] > tmp:
num[j] = num[j-1]
j -= 1
num[j] = tmp
for i in range(n):
if i==n-1:
print(num[i], end='')
break
print(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
| 30,770 |
s929905230 | p02255 | u821624310 | 1498083135 | Python | Python3 | py | Accepted | 30 | 8056 | 453 | N = int(input())
A = [int(A) for A in input().split()]
for k in range(N):
if k == N -1:
print("{}".format(A[k]))
else:
print("{}".format(A[k]), end = " ")
for i in range(1, N):
j = i -1
v = A[i]
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
for k ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,771 |
s686752752 | p02255 | u747635679 | 1498168069 | Python | Python3 | py | Accepted | 20 | 7664 | 253 | n = int(input())
tmp = input()
print(tmp)
a = [int(x) for x in tmp.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,772 |
s866644209 | p02255 | u591467586 | 1498202102 | Python | Python3 | py | Accepted | 30 | 8172 | 516 | def insertionSort(N,A):
for i in range(0,N):
innum = A[i]
j = i - 1
while j>=0 and innum < A[j]:
A[j+1] = A[j]
j = j -1
A[j+1] = innum
for j in range(0,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
| 30,773 |
s013995356 | p02255 | u591467586 | 1498203099 | Python | Python3 | py | Accepted | 40 | 7960 | 339 | N = int(input())
A = (input()).split()
for i in range(0,N):
A[i] = int(A[i])
for i in range(0,N):
innum = A[i]
j = i - 1
while j>=0 and innum < A[j]:
A[j+1] = A[j]
j = j -1
A[j+1] = innum
for j in range(0,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
| 30,774 |
s217253538 | p02255 | u936051377 | 1498364132 | Python | Python3 | py | Accepted | 30 | 7688 | 332 | list_len = int(input().rstrip())
num_list = list(map(int, input().rstrip().split()))
for i in range(list_len):
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
output_str = ' '.join(map(str, num_list))
print... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,775 |
s792492476 | p02255 | u821624310 | 1498367799 | Python | Python3 | py | Accepted | 30 | 7984 | 391 | def printf(N, A):
for cnt in range(N):
if cnt == N - 1:
print("{}".format(A[cnt]))
else:
print("{}".format(A[cnt]), end=' ')
N = int(input())
A = [int(A) for A in input().split()]
printf(N, A)
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > 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,776 |
s209390171 | p02255 | u936051377 | 1498376908 | Python | Python3 | py | Accepted | 20 | 7748 | 398 | def insertion_sort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(' '.join(map(str, A)))
def main():
N = int(input().rstrip())
A = list(map(int, input().rstrip().spli... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 30,777 |
s022317415 | p02255 | u591875281 | 1498405278 | Python | Python3 | py | Accepted | 20 | 8024 | 341 | def insertionSort(A, N):
for i in range(1, N):
print (*A)
v = A[i]
j = i - 1
while j>= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
return A
if __name__ == "__main__":
N = int(input())
A = [int(i) for i in input().split()]
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,778 |
s638058985 | p02255 | u936051377 | 1498642494 | Python | Python3 | py | Accepted | 40 | 7656 | 390 | def insertion_sort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(' '.join(map(str, A)))
def main():
N = int(input().rstrip())
A = list(map(int, input().rstrip().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,779 |
s509185877 | p02255 | u044225038 | 1498695452 | Python | Python3 | py | Accepted | 20 | 7724 | 310 | def insertion(A):
for i in range(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([str(x) for x in A]))
N = int(input())
A = [int(x) for x in input().strip().split(' ')]
insertion(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,780 |
s915370032 | p02255 | u278938795 | 1498724535 | Python | Python | py | Accepted | 10 | 6452 | 296 | import sys
def printlist(lst):
for l in lst:
print(l),
print
N = int(sys.stdin.readline().strip())
A = sys.stdin.readline().strip().split(" ")
A = map(lambda x:int(x),A)
for i in range(0,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
printlist(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,781 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.