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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s981787651 | p02255 | u726954442 | 1594350544 | Python | Python3 | py | Accepted | 20 | 5976 | 496 | def Insert_sort(array,N):
for i in range(1,N):
temp = array[i]
j = i - 1
print(*array)
while(j >= 0 ) and (array[j] >= temp):
array[j+1] = array[j]
j -= 1
array[j+1] = temp
print(*array)
#array= ' '.join(array)
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,082 |
s691296431 | p02255 | u389029213 | 1594310374 | Python | Python3 | py | Accepted | 20 | 5600 | 415 | #入力
n = int(input())
elements = [int(n) for n in input().split()]
print(' '.join(map(str, elements)))
#未ソート部分の先頭を取り出す
for i in range(1,n):
v = elements[i]
j = i - 1
#ソート部分から挿入場所を決定する。
while j >= 0 and elements[j] > v :
elements[j+1] = elements[j]
j -= 1
elements[j+1] = v
print('... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,083 |
s734720336 | p02255 | u128683476 | 1594287749 | Python | Python | py | Accepted | 10 | 4648 | 226 | 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
| 31,084 |
s054745459 | p02255 | u040188532 | 1594285175 | Python | Python3 | py | Accepted | 20 | 5592 | 223 | _ = input()
a = list(map(int, input().split()))
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(map(str,a)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,085 |
s087067015 | p02255 | u829817944 | 1594238549 | Python | Python3 | py | Accepted | 20 | 5604 | 434 | def insertion_sort(A, N):
for i in range(1, N, 1):
A_str = [str(x) for x in A]
print(" ".join(A_str))
v = int(A[i])
j = i - 1
while j >= 0 and int(A[j]) > v:
A[j + 1] = int(A[j])
j = j - 1
A[j + 1] = v
A_str = [str(x) for x in A]
print(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,086 |
s504075392 | p02255 | u880802684 | 1594111548 | Python | Python3 | py | Accepted | 20 | 5612 | 424 | import sys
input = sys.stdin.readline
def insertionSort(A):
for i in range(len(A)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join([str(a) for a in A]))
def main():
_ = int(input().strip())
A = ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,087 |
s986990254 | p02255 | u508539251 | 1594061975 | Python | Python3 | py | Accepted | 20 | 5984 | 194 | n, *aa = map(int, open(0).read().split())
for i in range(n):
j = i
while j-1 >= 0:
if aa[j-1] > aa[j]:
aa[j-1], aa[j] = aa[j], aa[j-1]
j -= 1
print(*aa)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,088 |
s265439811 | p02255 | u437548816 | 1593940157 | Python | Python3 | py | Accepted | 20 | 5596 | 472 | # incert sort
N = int(input())
list_num = list(map(int, input().split(" ")))
print(" ".join(map(str, list_num)))
for i_incert in range(1, N):
num_incert = list_num[i_incert]
i_cmpr = i_incert - 1
while i_cmpr >= 0 and list_num[i_cmpr] > num_incert:
list_num[i_cmpr + 1] = list_num[i_cmpr] # 一つ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,089 |
s069880410 | p02255 | u286677087 | 1593876652 | Python | Python3 | py | Accepted | 20 | 5596 | 249 | 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 l[j] > v and j >= 0:
l[j+1] = l[j]
j -= 1
l[j+1] = v
print(' '.join(map(str, l)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,090 |
s789784680 | p02255 | u781733722 | 1593868052 | Python | Python3 | py | Accepted | 20 | 5608 | 536 | N = int(input())
A = list(map(int, input().split()))
for i in range(N):
v = A[i]
if v >= A[0]:
j = 0
while v >= A[j] and j < i:
j = j + 1
if j < i:
for k in reversed(range(j, i)):
A[k + 1] = A[k]
A[j] = v
print(' '.join([st... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,091 |
s471257484 | p02255 | u541181365 | 1593765889 | Python | Python3 | py | Accepted | 20 | 5596 | 284 | n = int(input())
nums = list(map(int, input().split()))
for idx1 in range(len(nums)):
num = nums[idx1]
idx2 = idx1 - 1
while idx2 >= 0 and nums[idx2] > num:
nums[idx2 + 1] = nums[idx2]
idx2 -= 1
nums[idx2+1] = num
print(" ".join(map(str, nums)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,092 |
s235832622 | p02255 | u229478139 | 1593763128 | Python | Python3 | py | Accepted | 20 | 5600 | 392 | def insertion_sort(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(list(map(str,A))))
if __name__ == '__main__':
n = int(input())
l = list(map(int, input(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,093 |
s583150325 | p02255 | u491441348 | 1593618459 | Python | Python3 | py | Accepted | 20 | 5976 | 202 | 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,sep=' ')
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,094 |
s152903100 | p02255 | u016268270 | 1593597944 | Python | Python3 | py | Accepted | 20 | 5604 | 160 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
b = sorted(a[:i+1])
b.extend(a[i+1:])
print(' '.join([str(i) for i in b]))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,095 |
s238192542 | p02255 | u920969712 | 1593514936 | Python | Python3 | py | Accepted | 20 | 5604 | 438 | def insertionSort(arr):
# Traverse through 1 to len(arr)
for i in range(1, len(arr)):
key = arr[i]
j = i - 1
while j >=0 and key < arr[j] :
arr[j+1] = arr[j]
j -= 1
arr[j+1] = key
print(' '.join(map(str, 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
| 31,096 |
s652761491 | p02255 | u075087498 | 1593509495 | Python | Python3 | py | Accepted | 20 | 5980 | 183 | N=int(input())
A=list(map(int,input().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j-=1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,097 |
s219313513 | p02255 | u083394909 | 1593501063 | Python | Python3 | py | Accepted | 30 | 5976 | 321 | n = int(input())
A = list(map(int, input().split()))
for i in range(1, n):
for m in range(n-1):
print(A[m], end=' ')
print(A[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
for m in range(n-1):
print(A[m], end=' ')
print(A[n-1])... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,098 |
s119676730 | p02255 | u783987868 | 1593392089 | Python | Python3 | py | Accepted | 20 | 5596 | 242 | n = int(input())
a = list(map(int,input().split()))
print(' '.join(map(str, a)))
for i in range(1,n):
v = a[i]
j = i -1
while j>=0 and a[j]>v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str, a)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,099 |
s697452699 | p02255 | u659868393 | 1593099172 | Python | Python3 | py | Accepted | 20 | 5608 | 464 | def main():
card_num = int(input())
cards = list(map(int, input().split()))
res = " ".join([str(n) for n in cards])
print(res)
for i in range(1, card_num):
v = cards[i]
j = i - 1
while j >= 0 and cards[j] > v:
cards[j + 1] = cards[j]
j -= 1
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,100 |
s645988945 | p02255 | u973203074 | 1593085476 | Python | Python3 | py | Accepted | 20 | 5980 | 239 | n = int(input())
A = [int(x) for x in input().split()]
for i in range(1, n + 1):
print(*A)
if i >= n: break
key = A[i]
j = i - 1
while j >= 0 and A[j] > key:
A[j + 1] = A[j]
j -= 1
A[j + 1] = key
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,101 |
s092490052 | p02255 | u467629721 | 1592970997 | Python | Python3 | py | Accepted | 20 | 5612 | 381 | def insertionSort(A, N):
for i in range(1, N):
print(" ".join([str(a) for a 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(a) for a in A]))
N = int(input().rstrip())
A = [int(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,102 |
s175606816 | p02255 | u187074069 | 1592917397 | Python | Python3 | py | Accepted | 20 | 5980 | 329 | N = int(input())
nums = list(map(int, input().split()))
def insertionSort(A, N):
for i in range(1, N):
show(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
show(A)
def show(lst):
print(*lst)
insertionSort(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,103 |
s707624713 | p02255 | u377776250 | 1592907678 | Python | Python3 | py | Accepted | 20 | 5596 | 281 | N = int(input())
line = list(map(int, input().split()))
print(' '.join(map(str, line)))
for i in range(1, N):
tmp = line[i]
j = i - 1
while j >= 0 and line[j] > tmp:
line[j + 1] = line[j]
j -= 1
line[j + 1] = tmp
print(' '.join(map(str, 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
| 31,104 |
s500016407 | p02255 | u857600946 | 1592842368 | Python | Python3 | py | Accepted | 20 | 5604 | 249 | N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, len(A)):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(list(map(str, A))))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,105 |
s419705785 | p02255 | u323905682 | 1592816181 | Python | Python3 | py | Accepted | 20 | 5604 | 326 | n = int(input())
a = list(map(int, input().split()))
def insertionSort(a, n):
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str, a)))
print(' '.join(map(str, a)))
insertionSort(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,106 |
s851370565 | p02255 | u691985124 | 1592815542 | Python | Python3 | py | Accepted | 20 | 5600 | 356 | def InsertionSort(A, N=1):
N = min(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
return A
N = int(input())
a = list(map(int, input().split()))
for i in range(len(a)):
print(' '.joi... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,107 |
s031264623 | p02255 | u684017359 | 1592727416 | Python | Python3 | py | Accepted | 20 | 5600 | 414 | n=int(input())
num_list=list(map(int,input().split()))
ans=str(num_list[0])
for k in range(1,len(num_list)):
ans+=" "+str(num_list[k])
print(ans)
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
ans=str(num_l... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,108 |
s056882871 | p02255 | u565737280 | 1592669464 | Python | Python3 | py | Accepted | 20 | 5596 | 223 | 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
A_=' '.join(map(str,A))
print(A_)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,109 |
s613351901 | p02255 | u386528873 | 1592664586 | Python | Python3 | py | Accepted | 20 | 5592 | 482 |
test_case_1_num = int(input())
test_case_1 = list(map(int,input().split()))
print(" ".join(map(str, test_case_1)))
for i in range(1, test_case_1_num):
t = test_case_1[i]
p = i
for j in range(0, i):
if t > test_case_1[j]:
continue
else:
for k in reversed(range(j,i)):... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,110 |
s446255012 | p02255 | u754923116 | 1592631390 | Python | Python3 | py | Accepted | 20 | 5604 | 384 | def main():
N = int(input())
A = list(map(int,input().split()))
print(' '.join(map(str,A)))
for i in range(1,N):
for j in range(i-1,-1,-1):
if A[j+1] >= A[j]:
break
elif A[j+1] < A[j]:
temp = A[j+1]
A[j+1] = A[j]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,111 |
s976589964 | p02255 | u677435639 | 1592630602 | Python | Python3 | py | Accepted | 20 | 5600 | 416 | def show(a):
ans=""
for c in a:
if c==a[-1]:
ans+=str(c)
else:
ans+=str(c)+" "
print(ans)
def insertionsort(a,n):
show(a)
for i in range(1,n):
v=a[i]
j=i-1
while j>=0 and a[j]>v:
a[j+1]=a[j]
j-=1
a[j... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,112 |
s086448241 | p02255 | u058106699 | 1592548476 | Python | Python3 | py | Accepted | 30 | 5984 | 591 | from sys import stdin
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
for j in range(N-1):
print(A[j], end=" ", sep=" ")
print(A[N-1])
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,113 |
s323104714 | p02255 | u562926655 | 1592406936 | Python | Python3 | py | Accepted | 20 | 5612 | 354 | import sys
input = sys.stdin.readline
def main():
N = int(input())
A = list(map(int, input().split()))
for i in range(N):
v = A[i]
j = i - 1
while 0 <= j and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(" ".join(map(str, A)))
if __... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,114 |
s310182628 | p02255 | u328484939 | 1592397206 | Python | Python3 | py | Accepted | 20 | 5980 | 171 | n=int(input())
A=list(map(int,input().split()))
for i in range(1,n):
print(*A)
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,115 |
s892220592 | p02255 | u560996731 | 1592375512 | Python | Python3 | py | Accepted | 20 | 5984 | 239 | #ALDS1_1_A: Insertion Sort
N = int(input())
A = list(map(int, input().split()))
print(*A)
for i in range(1, N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,116 |
s738153669 | p02255 | u645587822 | 1592297934 | Python | Python3 | py | Accepted | 30 | 5976 | 378 | n = int(input())
a = list(map(int, input().split()))
for x in a:
if x == a[n-1]:
print(x)
else:
print(x, 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 x in a:
if x == a[n-1]:
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,117 |
s525660633 | p02255 | u743876353 | 1592270587 | Python | Python3 | py | Accepted | 20 | 5600 | 245 | N=int(input())
A=list(map(int,input().split(" ")))
print(" ".join(list(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(list(map(str,A))))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,118 |
s200904567 | p02255 | u918401227 | 1592226047 | Python | Python3 | py | Accepted | 20 | 5980 | 339 | def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
def main():
N = int(input())
A = list(map(int, input().split()))
insertionSort(A, N)
if __name__ == '__m... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,119 |
s578603762 | p02255 | u814278309 | 1592221011 | Python | Python3 | py | Accepted | 20 | 5976 | 204 | n = int(input())
x = list(map(int,input().split()))
for i in range(n):
temp = x[i]
j = i - 1
while j>= 0 and x[j] > temp:
x[j+1] = x[j]
j -= 1
x[j+1] = temp
print(*x)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,120 |
s524219647 | p02255 | u465743080 | 1592206591 | Python | Python3 | py | Accepted | 40 | 6312 | 517 | def printTable(table):
for i in range(len(table)):
print(table[i], end='')
if i != len(table)-1:
print(' ', end='')
print()
def insertionSort(table):
for i in range(1, len(table)):
min = table[i]
j = i - 1
while j >= 0 and min < table[j]:
tab... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,121 |
s854671733 | p02255 | u430753724 | 1592142198 | Python | Python3 | py | Accepted | 20 | 5612 | 422 | # -*- coding: utf-8 -*-
from sys import stdin
def insertionSort(A, N): #N個の要素を含む0−オリジンの配列
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(stdin.readline().rstri... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,122 |
s528980013 | p02255 | u678754522 | 1592138977 | Python | Python3 | py | Accepted | 20 | 5596 | 245 | n = int(input())
lis = list(map(int, input().split()))
print(" ".join(map(str, lis)))
for i in range(1, n):
v = lis[i]
j = i - 1
while j >= 0 and lis[j] > v:
lis[j+1] = lis[j]
j -= 1
lis[j+1] = v
print(" ".join(map(str, lis)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,123 |
s445672779 | p02255 | u532816932 | 1592099388 | Python | Python3 | py | Accepted | 20 | 5612 | 476 | # coding: utf-8
# Your code here!
N = int(input())
arr = list(map(int,input().split()))
#print(N,arr)
print(" ".join(str(x) for x in arr))
def insertionSort(N,arr):
for i in range(1,N):
v = arr[i]
j = i - 1
while j >= 0 and arr[j] > v:
arr[j+1] = arr[j]
j -= 1
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,124 |
s779401463 | p02255 | u732319676 | 1592093059 | Python | Python3 | py | Accepted | 20 | 5980 | 216 | n = input()
A = list(map(int, 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
| 31,125 |
s328932061 | p02255 | u171087702 | 1592058053 | Python | Python3 | py | Accepted | 20 | 5604 | 235 | N = int(input())
A = list(map(int, input().split()))
print(' '.join(map(str, A)))
for i in range(1, N):
j = i
while j >= 1 and A[j] < A[j-1]:
A[j-1], A[j] = A[j], A[j-1]
j -= 1
print(' '.join(map(str, A)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,126 |
s255278139 | p02255 | u805969710 | 1592018607 | Python | Python3 | py | Accepted | 20 | 5984 | 169 | N=int(input())
A=list(map(int,input().split()))
for i in range(1,N):
print(*A)
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,127 |
s271211836 | p02255 | u245986106 | 1592008463 | Python | Python3 | py | Accepted | 20 | 5976 | 517 | #1 insertionSort(A, N) // N個の要素を含む0-オリジンの配列A
#2 for i が 1 から N-1 まで
#3 v = A[i]
#4 j = i - 1
#5 while j >= 0 かつ A[j] > v
#6 A[j+1] = A[j]
#7 j--
#8 A[j+1] = v
def insertionSort(A, N):
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
| 31,128 |
s618506934 | p02255 | u557026017 | 1591986618 | Python | Python3 | py | Accepted | 20 | 5604 | 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
| 31,129 |
s402462731 | p02255 | u761136522 | 1591754040 | Python | Python3 | py | Accepted | 20 | 5604 | 385 | def insertionSort(A, N):
print(' '.join(map(str, A)))
for i in range(1, N):
value = A[i]
j = i - 1
while j >= 0 and A[j] > value:
A[j + 1] = A[j]
j -= 1
A[j + 1] = value
print(' '.join(map(str, A)))
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
| 31,130 |
s848057141 | p02255 | u925888550 | 1591701023 | Python | Python3 | py | Accepted | 20 | 5984 | 207 | n = int(input())
A = list(map(int, input().split()))
for i in range(0,n):
v = A[i]
j = i -1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j-=1
A[j+1] = v
print(*A,sep=" ")
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,131 |
s462586556 | p02255 | u076766682 | 1591668952 | Python | Python3 | py | Accepted | 20 | 5596 | 223 | n=int(input())
l=list(map(int,input().split()))
print(" ".join(map(str,l)))
for i in range(1,n):
v=l[i]
j=i-1
while j>=0 and l[j]>v:
l[j+1]=l[j]
j-=1
l[j+1]=v
print(" ".join(map(str,l)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,132 |
s420725328 | p02255 | u230966134 | 1591662842 | Python | Python3 | py | Accepted | 20 | 5600 | 285 | N = int(input())
cards = list(map(int,input().split()))
print(" ".join(map(str,cards)))
for i in range(1,N):
tmp = cards[i]
j = i - 1
while j >= 0 and tmp < cards[j]:
cards[j+1] = cards[j]
cards[j] = tmp
j -= 1
print(" ".join(map(str,cards)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,133 |
s802609064 | p02255 | u668339719 | 1591582549 | Python | Python3 | py | Accepted | 40 | 5976 | 408 | N = int(input())
array = list(map(int,input().split()))
for dt in array:
if dt==array[-1]:
print(dt)
else:print(dt,end=" ")
for n in range(1,N):
for m in range(n-1,-1,-1):
if array[m]>array[m+1]:
tmp=array[m]
array[m]=array[m+1]
array[m+1]=tmp
for dt i... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,134 |
s869723507 | p02255 | u469572282 | 1591408524 | Python | Python3 | py | Accepted | 20 | 5976 | 197 | n = int(input())
A = list(map(int, input().split()))
for i in range(n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,135 |
s562091328 | p02255 | u322107177 | 1591365603 | Python | Python3 | py | Accepted | 30 | 5976 | 452 | n = int(input())
a = list(map(int, input().split()))
def print_space(li):
for i in range(len(li)-1):
print(li[i], end=' ')
else:
print(li[-1])
def InsertionSort(li):
print_space(li)
for i in range(1, n):
v = li[i]
j = i - 1
while j >= 0 and li[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
| 31,136 |
s666951090 | p02255 | u170051165 | 1591347629 | Python | Python3 | py | Accepted | 20 | 5612 | 387 | import sys
input = sys.stdin.readline
def insertion_sort(n,a):
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str,a)))
return a
if __name__ == "__main__":
n = int(input(... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,137 |
s414375387 | p02255 | u121616304 | 1591274159 | Python | Python3 | py | Accepted | 30 | 5604 | 220 | N=int(input())
S=list(map(int,input().split()))
for i in range(N):
v=S[i]
j=i-1
while j>=0 and S[j]>v:
S[j+1] =S[j]
j-=1
S[j+1]=v
Z=[str(a) for a in S]
Z=" ".join(Z)
print(Z)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,138 |
s917403980 | p02255 | u266640508 | 1591225889 | Python | Python3 | py | Accepted | 20 | 5600 | 308 | def show(A):
output = ""
for i in range(len(A)):
output += str(A[i]) + " "
print(output[:-1])
def insertionsort(A, N):
for i in range(1, N):
show(A)
A[:i+1] = sorted(A[:i+1])
show(A)
N = int(input())
A = list(map(int, input().split()))
insertionsort(A, N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,139 |
s764464543 | p02255 | u048101135 | 1591186554 | Python | Python3 | py | Accepted | 20 | 5608 | 322 | def insertionSort(N,A):
print(" ".join(map(str,A)))
for i in range(1,N):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str,A)))
insertionSort(int(input()),list(map(int,input().split())))
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,140 |
s022707070 | p02255 | u670406235 | 1591041731 | Python | Python3 | py | Accepted | 30 | 5980 | 547 | def print_list(A):
for x in range(len(A) - 1):
print(A[x],end = " ")
print(A[len(A) - 1])
def insertionsort(A,n):
count = 0
for i in range(1,n):
print_list(A)
right = i
left = i - 1
while A[left] > A[right] and left >= 0:
A[left],A[right] = A[right],A... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,141 |
s606714640 | p02255 | u523009684 | 1590976445 | Python | Python3 | py | Accepted | 30 | 5980 | 509 | def show_nums(nums):
for i in range(len(nums)):
if i != len(nums) - 1:
print(A[i], end = ' ')
else:
print(A[i])
N = int(input())
input_list = input().split(' ')
A = []
for i in input_list:
A.append(int(i))
if len(input_list) != N:
raise ValueError('N個の整数... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,142 |
s021641637 | p02255 | u778770195 | 1590911771 | Python | Python3 | py | Accepted | 20 | 5600 | 397 | # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A
from sys import stdin
input = lambda: stdin.readline().rstrip()
N = int(input())
A = list(map(int, input().split()))
join = lambda a : ' '.join(map(str, a))
print(join(A))
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] >... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,143 |
s330109460 | p02255 | u053277556 | 1590902629 | Python | Python3 | py | Accepted | 20 | 5980 | 367 | def insertion_sort(A,N):
sorted_A = A.copy()
print(*sorted_A)
for i in range(1,N):
v = sorted_A[i]
j = i-1
while (j>=0)&(sorted_A[j]>v):
sorted_A[j+1] = sorted_A[j]
j -= 1
sorted_A[j+1] = v
print(*sorted_A)
N = int(input())
A = list(m... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,144 |
s988663356 | p02255 | u256637043 | 1590758535 | Python | Python3 | py | Accepted | 20 | 5604 | 302 | # ALDS1_1_A.py
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(_) for _ in a]))
N = int(input())
A = list(map(int,input().split()))
insertionSort(A,N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,145 |
s139435702 | p02255 | u153034461 | 1590687147 | Python | Python3 | py | Accepted | 30 | 6712 | 476 | import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy
import bisect
import functools
def InsertionSort(A):
for i in range(1,len(A)):
key = A[i]
j = i - 1
while j>=0 and A[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
| 31,146 |
s764613279 | p02255 | u390052013 | 1590626300 | Python | Python3 | py | Accepted | 20 | 5984 | 338 | 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
print(*A)
def resolve():
N = int(input())
A = [int(i) for i in input().split()]
insertionSort(A... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,147 |
s558810516 | p02255 | u859623080 | 1590318586 | Python | Python3 | py | Accepted | 30 | 5980 | 312 | n = int(input())
A = list(map(int, input().split()))
for i in range(n) :
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
for j in range(n):
if j == n - 1 :
print(A[j])
else:
print(str(A[j]) + " ", end="")
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,148 |
s549172838 | p02255 | u662073530 | 1590315289 | Python | Python3 | py | Accepted | 20 | 5604 | 332 | N = int(input())
arr = list(map(int,input().split()))
def insertionSort(arr, n):
for i in range(1,n):
v=arr[i]
j=i-1
while j>=0 and arr[j]>v:
arr[j+1] = arr[j]
j=j-1
arr[j+1] = v
print(' '.join(map(str, arr)))
print(' '.join(map(str, arr)))
insertionS... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,149 |
s800382838 | p02255 | u137561642 | 1590314002 | Python | Python3 | py | Accepted | 20 | 5596 | 293 | size = int(input())
l = []
for i in map(int, input().split()):
l.append(i)
print(' '.join(map(str,l)))
for i in range(1,size):
tmp = l[i]
j = i - 1
while l[j] > tmp and j >= 0:
l[j + 1] = l[j]
j = j - 1
l[j + 1] = tmp
print(' '.join(map(str,l)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,150 |
s744337098 | p02255 | u822440951 | 1590313936 | Python | Python3 | py | Accepted | 20 | 5592 | 247 | n = int(input())
a = list(map(int, input().split()))
print(' '.join(map(str, a)))
for i in range(1, n):
v = a[i]
j = i-1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(' '.join(map(str, a)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,151 |
s399584567 | p02255 | u592859274 | 1590286787 | Python | Python3 | py | Accepted | 30 | 5976 | 367 | def insertion_sort(A: list, N: int):
print(*A, sep=" ")
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A, sep=" ")
if __name__ == "__main__":
N = int(input())
A = list(map(in... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,152 |
s250130449 | p02255 | u512884261 | 1590245360 | Python | Python3 | py | Accepted | 20 | 6036 | 647 | import sys
input = lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,153 |
s639521610 | p02255 | u275308599 | 1590245078 | Python | Python3 | py | Accepted | 20 | 5604 | 305 | def insertionSort(A,N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str,A)))
n = int(input())
numlist = [int(x) for x in input().split()]
insertionSort(numlist,n)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,154 |
s028708191 | p02255 | u736320234 | 1590119981 | Python | Python3 | py | Accepted | 20 | 5976 | 189 | n = int(input())
a = list(map(int,input().split()))
tmp=0
for i in range(n):
j=i
tmp=a[i]
while a[j-1]>tmp and j>0:
a[j]=a[j-1]
j-=1
a[j]=tmp
print(*a)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,155 |
s689901297 | p02255 | u795389818 | 1589989176 | Python | Python3 | py | Accepted | 20 | 5980 | 202 | 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 v<l[j]:
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
| 31,156 |
s239861745 | p02255 | u475213171 | 1589952557 | Python | Python3 | py | Accepted | 30 | 5980 | 434 | def insertion_sort(seq):
n = len(seq)
for i in range(n):
v = seq[i]
j = i-1
while j >= 0 and seq[j] > v:
seq[j+1] = seq[j] #vの入る候補がindexのi-1
j -= 1
seq[j+1] = v
print(seq[0], end='')
for k in range(1, n):
print(' '+str(seq[k]), ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,157 |
s603082237 | p02255 | u624480730 | 1589888442 | Python | Python3 | py | Accepted | 20 | 5984 | 209 | 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
| 31,158 |
s276181258 | p02255 | u429798035 | 1589872503 | Python | Python3 | py | Accepted | 30 | 5980 | 423 | def show(lst):
length = len(lst)
for i in range(length-1):
print(lst[i], end=" ")
print(lst[-1])
n = int(input())
lst = list(map(int, input().split()))
def insertion_sort(lst, n):
for i in range(n):
v = lst[i]
j = i - 1
while j >= 0 and lst[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
| 31,159 |
s973742573 | p02255 | u878424017 | 1589821826 | Python | Python3 | py | Accepted | 20 | 5596 | 216 | n = int(input())
A = list(map(int,input().split()))
for i in range(n):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str,A)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,160 |
s892875216 | p02255 | u235534975 | 1589813372 | Python | Python3 | py | Accepted | 20 | 5980 | 207 | 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)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,161 |
s448470093 | p02255 | u849026497 | 1589807112 | Python | Python3 | py | Accepted | 30 | 5976 | 430 | N = int(input())
a = [int(i) for i in input().split() ]
for j in range(len(a)):
if j == len(a) -1:
print(a[j],end = "")
else:
print(a[j],end = " ")
print()
for i in range(1,len(a)):
tmp = a[i]
j = i- 1
while j >= 0 and a[j] > tmp:
a[j+1] = a[j]
j -= 1
a[j+1] = tmp
for j in range(len(a)... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,162 |
s362466131 | p02255 | u124936061 | 1589732262 | Python | Python3 | py | Accepted | 30 | 5980 | 1,285 | #โชว์การ sort ในแต่ละบรรทัด
def show (seqs):
for i in range(len(seqs)):
if i!=len(seqs)-1:
print(seqs[i],end=' ')
else :
print(seqs[i])
num = int(input())
seqs = list(map(int,input().split()))
show(seqs) #โชว์ข้อมูลที่รับ input มา
for i in range(1,num):#วน loop เริ่มจาก 1 ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,163 |
s368118902 | p02255 | u704109794 | 1589729854 | Python | Python3 | py | Accepted | 20 | 5976 | 198 | n = int(input())
s = list(map(int, input().split()))
for i in range(n):
v = s[i]
j = i - 1
while j >= 0 and s[j] > v:
s[j+1] = s[j]
j -= 1
s[j+1] = v
print(*s)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,164 |
s285188135 | p02255 | u849967894 | 1589723507 | Python | Python3 | py | Accepted | 20 | 5596 | 242 | n = int(input())
data = list(map(int, input().split()))
for i in range(1,n):
print(" ".join(map(str, data)))
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
| 31,165 |
s804393109 | p02255 | u740184621 | 1589714553 | Python | Python3 | py | Accepted | 20 | 5984 | 687 |
import sys
sys.setrecursionlimit(10 ** 7)
read = sys.stdin.buffer.read
inp = sys.stdin.buffer.readline
def inpS(): return inp().rstrip().decode()
readlines = sys.stdin.buffer.readlines
MOD = 10 ** 9 + 7
INF = 1 << 60
# ---------------------------------------------------
# ---------------------------------------------... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,166 |
s888761648 | p02255 | u216411223 | 1589707822 | Python | Python3 | py | Accepted | 20 | 5604 | 493 | def insertsort(N_list):
sort_list = list(N_list)
ans = [str(i) for i in sort_list]
print(" ".join(ans))
for i in range(1,len(N_list)):
target = sort_list[i]
j = i-1
while j >= 0 and sort_list[j] > target:
sort_list[j], sort_list[j+1] = target, sort_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
| 31,167 |
s176575274 | p02255 | u189869226 | 1589694812 | Python | Python3 | py | Accepted | 30 | 5984 | 364 | N = int(input())
A = list(map(int, input().split()))
def insertion_sort(A):
for idx, target in enumerate(A[1:]):
j = idx
while j >= 0 and A[j] > target:
A[j+1] = A[j]
j -= 1
A[j+1] = target
disp(A)
def disp(A):
for i in A[:-1]:
print(i, end=" ")
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,168 |
s915424814 | p02255 | u818861195 | 1589644842 | Python | Python3 | py | Accepted | 20 | 5980 | 315 | 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] = A[j],A[j+1]
# print(f'i={i} j={j}')
j -= 1
print(*A)
N = int(input())
A = list(map(int,input().split()))
insertionSort(A,N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,169 |
s834587761 | p02255 | u807310370 | 1589466359 | Python | Python3 | py | Accepted | 20 | 5976 | 197 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
a[j+1] = v
print(*a)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,170 |
s381620931 | p02255 | u765637740 | 1589425942 | Python | Python3 | py | Accepted | 30 | 5992 | 325 | N = int(input())
A = list(map(int,input().split()))
for k in range(N-1):
print(f"{A[k]} ",end="")
print(f"{A[N-1]}")
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
for k in range(N-1):
print(f"{A[k]} ",end="")
print(f"{A[N-1... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,171 |
s060497570 | p02255 | u951109227 | 1589418011 | Python | Python3 | py | Accepted | 20 | 5604 | 339 | def insert_sort(n:int, s:list):
print(' '.join(map(str, s)))
for i in range(1, len(s)):
j = i - 1
v = s[i]
while (j >= 0 and s[j] > v):
s[j + 1] = s[j]
j -= 1
s[j + 1] = v
print(" ".join(map(str, s)))
insert_sort(int(input()),list(map(int,inpu... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,172 |
s920788295 | p02255 | u914376877 | 1589203870 | Python | Python3 | py | Accepted | 20 | 5976 | 290 | def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
return A
N = int(input())
A = list(map(int, input().split()))
insertionSort(A, N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,173 |
s975217096 | p02255 | u716887178 | 1589166082 | Python | Python3 | py | Accepted | 20 | 5604 | 302 | def Insertion_Sort(a,n):
for i in range(1,n+1):
print(' '.join(map(str,a)))
if n > i:
temp = a[i]
j = i - 1
while j >= 0 and a[j] > temp:
a[j+1] = a[j]
j -= 1
a[j+1] = temp
num = int(input())
s = list(map(int,input().split()))
Insertion_Sort(s,num)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,174 |
s038227179 | p02255 | u090815677 | 1589111611 | Python | Python3 | py | Accepted | 20 | 6128 | 349 | import sys
import math
import itertools
def insertionSort(A, N):
for i in range(N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
def main():
N = int(input())
numbers = list(map(int, input().split()))
insertionSort(numbers, N)
if __na... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,175 |
s953082572 | p02255 | u162097481 | 1588951326 | Python | Python3 | py | Accepted | 20 | 5604 | 309 | N = int(input())
A = list(map(int, input().split()))
for i in range(1, N+1):
for j in reversed(range(1, i)):
if A[j] < A[j-1]:
tmp = A[j]
A[j] = A[j-1]
A[j-1] = tmp
else:
break
result = [str(k) for k in A]
print(' '.join(result))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,176 |
s610298787 | p02255 | u864060739 | 1588934737 | Python | Python3 | py | Accepted | 20 | 5980 | 250 | from sys import stdin
N = int(stdin.readline())
A = list(map(int, stdin.readline().split()))
print(*A)
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,177 |
s602800336 | p02255 | u823156797 | 1588907857 | Python | Python3 | py | Accepted | 30 | 5980 | 403 | def show (seqs):
for i in range(len(seqs)):
if i != len(seqs)-1:
print(seqs[i], end = ' ')
else :
print(seqs[i])
num = int(input())
seqs = list(map(int,input().split()))
show(seqs)
for i in range(1,num):
element = seqs[i]
j = i-1
while (j>=0 and seqs[j]>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
| 31,178 |
s724520263 | p02255 | u280197618 | 1588894493 | Python | Python3 | py | Accepted | 20 | 5976 | 193 | n = int(input())
*A, = map(int, input().split())
for i in range(n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,179 |
s119539982 | p02255 | u548184870 | 1588852361 | Python | Python3 | py | Accepted | 20 | 5604 | 272 | n = int(input()) # 6
a = list(map(int, input().split())) # [1, 4, 3, 6, 2, 5]
print(' '.join([str(n) for n in a]))
for i in range(1, len(a)):
j = a[i]
for k in range(i - 1, -1, -1):
if a[k] > j:
a[k + 1] = a[k]
a[k] = j
print(' '.join([str(n) for n in a]))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,180 |
s879388859 | p02255 | u131892700 | 1588845705 | Python | Python3 | py | Accepted | 30 | 5980 | 435 | 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
b = 0
for i in A:
b +=1
if b == N:
print(i, end ="")
else:
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,181 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.