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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
s356505796 | p02255 | u446026124 | 1560229479 | 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,582 |
s623465982 | p02255 | u061534441 | 1560176443 | Python | Python3 | py | Accepted | 30 | 5980 | 378 | N = int(input())
A = list(map(int, input().split()))
def show(arr):
for k in range(len(arr)):
if k != len(arr) - 1:
print(arr[k], end=' ')
else:
print(arr[k])
# 挿入ソート
for i in range(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
| 31,583 |
s465121823 | p02255 | u453734454 | 1560143624 | Python | Python3 | py | Accepted | 30 | 5596 | 223 | 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,584 |
s337229941 | p02255 | u224841433 | 1559895674 | Python | Python3 | py | Accepted | 20 | 5608 | 314 | 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 = list(map(int, input().split()))
A = insertionsort(A, N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,585 |
s186776013 | p02255 | u554902881 | 1559789819 | Python | Python3 | py | Accepted | 30 | 5984 | 486 | def show(lists):
for i in range(len(lists)):
if i != len(lists) - 1:
print(lists[i], end=' ')
else: print(lists[i])
length = int(input())
List = list(map(int, input().split()))
for i in range(length):
term = List[i]
j = i - 1
while j >= 0 and List[j] > term: #ここで変数をiからjに置き換... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,586 |
s753643410 | p02255 | u653744760 | 1559645112 | Python | Python3 | py | Accepted | 30 | 5980 | 319 | n=int(input())
a=list(map(lambda x:int(x),list(input().split())))
for i in range(1,n):
for k in range(n-1):
print(a[k],end=" ")
print(a[n-1])
v=a[i]
j=i-1
while j>=0 and a[j]>v:
a[j+1]=a[j]
j=j-1
a[j+1]=v
for 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
| 31,587 |
s196341401 | p02255 | u208260150 | 1559644913 | Python | Python3 | py | Accepted | 30 | 5976 | 367 | n=int(input())
a=list(map(int,input().split()))
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):
if i==n-1:
print(a[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,588 |
s307175499 | p02255 | u902579831 | 1559118522 | Python | Python3 | py | Accepted | 20 | 5980 | 354 | def insertionSort(A, N):
for i in range(1, N):
print(*A, sep=" ")
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=" ")
return A
N = int(input())
list_num = 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,589 |
s052305119 | p02255 | u726481755 | 1558840102 | Python | Python3 | py | Accepted | 20 | 5600 | 241 | N = int(input())
A = list(map(int,input().split()))
print(" ".join(list(map(str,A))))
for i in range(1,N):
v= A[i]
j= i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(" ".join(list(map(str,A))))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,590 |
s704435977 | p02255 | u454636644 | 1558372532 | Python | Python3 | py | Accepted | 20 | 5604 | 364 | def insertionSort(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)))
if __name__ == "__main__":
N = int(input())
A = list(map(i... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,591 |
s055762278 | p02255 | u822165491 | 1558183644 | Python | Python3 | py | Accepted | 20 | 5608 | 291 | N = int(input())
A = list(map(int, input().split()))
print(' '.join([str(a) for a in A]))
for i in range(1, N):
v = A[i]
j = i - 1
while (j>=0) and (A[j]>v):
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(' '.join([str(a) for a in A]))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,592 |
s107915405 | p02255 | u566160059 | 1558178642 | Python | Python3 | py | Accepted | 20 | 5600 | 357 | def pr(sequence):
string = ''
for i in sequence[:-1]:
string += str(i) + ' '
string += str(sequence[-1])
print(string)
n = int(input())
a = list(map(int, input().split()))
for i in range(1,n):
pr(a)
key = a[i]
j = i -1
while (j >=0) and (a[j] > key):
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,593 |
s242980131 | p02255 | u100569186 | 1558172707 | Python | Python3 | py | Accepted | 20 | 5980 | 200 | N = int(input())
A = list(map(int, input().split()))
print(*A)
for i in range(1, N):
while A[i] < A[i-1] and i-1 >= 0:
temp = A[i-1]
A[i-1] = A[i]
A[i] = temp
i -= 1
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,594 |
s114235261 | p02255 | u412294315 | 1558083779 | Python | Python3 | py | Accepted | 30 | 5976 | 382 | def print_array(data):
for i in range(len(data)):
if i != len(data)-1:
print("%d" % data[i],end=" ")
else:
print("%d" % data[i])
if __name__ == '__main__':
num = int(input())
a = [int(i) for i in input().split()]
for i in range(1,num):
print_array(a)
key = a[i]
j = i - 1
while j >= 0 and a[j] > 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,595 |
s303947958 | p02255 | u970810709 | 1558010656 | Python | Python3 | py | Accepted | 20 | 5608 | 263 | #ALDS1_1_A
n = int(input())
a = [int(i) for i in input().split()]
for i in range(1,n):
print(" ".join([str(t) for t 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(t) for t 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,596 |
s252093776 | p02255 | u901413584 | 1557990385 | Python | Python3 | py | Accepted | 30 | 5976 | 346 | N = int(input())
a = list(map(int, input().strip().split()))
for j in range (1,N):
for i in range(0, N-1):
print(a[i], end=" ")
print(a[N-1])
temp = a[j]
for k in range(0,j):
if(temp<a[k]):
a.pop(j)
a.insert(k,temp)
break
for l in range(0, N-1):
print(a[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,597 |
s865197540 | p02255 | u679210025 | 1557972007 | Python | Python3 | py | Accepted | 30 | 5980 | 326 | def lP(l: list) -> None:
for i in range(len(l)-1):
print(l[i], end = ' ')
print(l[len(l)-1])
N = int(input())
l = list(map(int, input().split()))
for i in range(1, N):
lP(l)
v = l[i]
for j in range(i-1, -1, -1):
if v >= l[j]:
break
l[j+1] = l[j]
l[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,598 |
s525012164 | p02255 | u511037423 | 1557961769 | Python | Python3 | py | Accepted | 20 | 5604 | 342 | N = int(input())
A = list(map(int, input().split()))
def insertationSort(A, N):
for i in range(1, N):
print(" ".join(map(str, A)))
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(map(str, A)))
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,599 |
s326836664 | p02255 | u340503368 | 1557900876 | Python | Python3 | py | Accepted | 20 | 5604 | 300 | num = int(input())
A = list(map(int, input().split()))
A_str = [str(a) for a in A]
print(' '.join(A_str))
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
A_str = [str(a) for a in A]
print(' '.join(A_str))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,600 |
s390322132 | p02255 | u928633434 | 1557735721 | Python | Python3 | py | Accepted | 40 | 6324 | 423 | 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
printArray(A)
def printArray(A):
for i,x in enumerate(A):
if i != 0:
print(" ", end="")
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,601 |
s615335065 | p02255 | u420816052 | 1557720011 | Python | Python3 | py | Accepted | 20 | 5600 | 245 | N = int(input())
list = list(map(str, input().split()))
print(' '.join(list))
for i in range(1, N):
v = list[i]
j = i - 1
while j >= 0 and int(list[j]) > int(v):
list[j+1] = list[j]
j += -1
list[j+1] = v
print(' '.join(list))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,602 |
s516825920 | p02255 | u847540062 | 1557575113 | Python | Python3 | py | Accepted | 20 | 5984 | 215 | a = int(input())
n = list(map(int, input().split()))
print(*n)
for i in range(1, a):
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(*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,603 |
s652110026 | p02255 | u951319620 | 1557451130 | Python | Python3 | py | Accepted | 30 | 5980 | 428 | N = int(input())
A = list(map(int, input().split()))
for i in range(1, N):
for k in range(N):
if k != N - 1:
print(A[k], end=" ")
else:
print(A[N-1], end="")
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,604 |
s886617998 | p02255 | u567306474 | 1557313618 | Python | Python3 | py | Accepted | 20 | 5604 | 277 | N = int(input())
A = [int(x) for x in input().split()]
print(" ".join(str(x) for x in 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(str(x) for x in A))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,605 |
s019090451 | p02255 | u610816226 | 1557220950 | Python | Python3 | py | Accepted | 20 | 5608 | 285 | num = int(input())
lis = list(map(int, input().split()))
print(' '.join([str(h) for h in lis]))
for i in range(1, num):
v = lis[i]
j = i - 1
while lis[j] > v and j >= 0:
lis[j + 1] = lis[j]
j -= 1
lis[j+1] = v
print(' '.join([str(h) for h in lis]))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,606 |
s074244976 | p02255 | u967268722 | 1557070788 | Python | Python3 | py | Accepted | 20 | 5976 | 228 | n = int(input())
data = list(map(int, input().split()))
print(*data)
for i in range(1, 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
| 31,607 |
s598212782 | p02255 | u532575143 | 1557023320 | Python | Python3 | py | Accepted | 20 | 5596 | 276 | n = int(input())
a_str = input()
print(a_str)
a = list(map(int, a_str.split()))
for i in range(0, n-1):
v = a[i+1]
j = i
while j >= 0 and a[j] > v:
a[j+1] = a[j]
j -= 1
#print(i, a, v, 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,608 |
s471597002 | p02255 | u757912388 | 1556029532 | Python | Python3 | py | Accepted | 20 | 5608 | 417 | n = int(input())
given_array = [int(x) for x in input().split()]
for i in range(1,n):
print(" ".join([str(x) for x in given_array]))
key = given_array[i]
j = i - 1
while j >= 0 and given_array[j] >= key:
temp = given_array[j]
given_array[j] = given_array[j+1]
given_array[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,609 |
s148544586 | p02255 | u332046103 | 1555587209 | Python | Python3 | py | Accepted | 30 | 5980 | 361 | def show(A):
for i in range(len(A)):
if i != len(A) - 1:
print(A[i], end=' ')
else:
print(A[i])
def insertionSort(n, A):
for i in range(1,n):
key = A[i]
j = i - 1
while (j >= 0 and A[j] > key):
A[j+1] = A[j]
j = j - 1
A[j+1] = key
show(A)
n = int(input())
nums = list(map(int, input().spl... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,610 |
s932271038 | p02255 | u064313887 | 1555502985 | Python | Python3 | py | Accepted | 30 | 5976 | 356 | N = int(input())
A = list(map(int,input().split()))
def show(nums):
for i in range(len(nums)):
if i != len(nums)-1:
print(nums[i],end=' ')
else:
print(nums[i])
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]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,611 |
s966619815 | p02255 | u840247626 | 1555432009 | Python | Python3 | py | Accepted | 20 | 5984 | 182 | 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,612 |
s493110389 | p02255 | u456917014 | 1555419348 | Python | Python3 | py | Accepted | 20 | 5980 | 188 | N=int(input())
A=list(map(int,input().split()))
print(*A)
for i in range(1, N):
v=A[i]
j=i-1
while j>=0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,613 |
s507389304 | p02255 | u955125993 | 1555416007 | Python | Python3 | py | Accepted | 20 | 5608 | 305 | N = int(input())
lst = [ int(i) for i in input().split() ]
lstr = [ str(c) for c in lst ]
print(" ".join(lstr))
for i in range(1, N):
v = lst[i]
j = i - 1
while 0 <= j and v < lst[j]:
lst[j + 1] = lst[j]
j -= 1
lst[j + 1] = v
lstr = [ str(c) for c in lst]
print(" ".join(lstr))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,614 |
s600330356 | p02255 | u485169607 | 1555309953 | Python | Python3 | py | Accepted | 20 | 5600 | 246 | n = int(input())
A = list(map(int, input().split()))
print(" ".join(map(str, A)))
for i in range(1, n):
v = A[i]
j = i-1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 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,615 |
s823284084 | p02255 | u792747184 | 1554697455 | Python | Python3 | py | Accepted | 30 | 5984 | 483 | N = int(input())
A = input().strip().split()
A = [int(i) for i in A]
for i in range(N):
if i == N-1:
print(A[i])
else:
print(A[i],end=' ')
for i in range(N-1):
j = i
while True:
if j == -1:
break
if A[j]>A[j+1]:
v = A[j]
A[j] = A[j+1]... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,616 |
s522200962 | p02255 | u105854386 | 1554652434 | Python | Python3 | py | Accepted | 20 | 5596 | 220 | 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,617 |
s020494617 | p02255 | u786568088 | 1554550983 | Python | Python3 | py | Accepted | 20 | 6096 | 4,883 | import sys
# import bisect
# import math
# import itertools
# import numpy as np
# import collections
"""Template"""
class IP:
"""
入力を取得するクラス
"""
def __init__(self):
self.input = sys.stdin.readline
def I(self):
"""
1文字の取得に使います
:return: int
"""
ret... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,618 |
s266523059 | p02255 | u387603681 | 1554439895 | Python | Python3 | py | Accepted | 20 | 5984 | 176 | 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,619 |
s082292939 | p02255 | u182167513 | 1554386703 | Python | Python3 | py | Accepted | 20 | 5600 | 581 | n = int(input())
nums = list(map(int,input().split()))
print(" ".join(map(str,nums)))
for i in range(1,n): #未ソートの部分列の先頭を示すループ変数
v = nums[i] #nums[i]の値を一時的に保持しておくための変数
j = i - 1 #ソート済み部分列からvを挿入するための位置を探すループ変数
while j >= 0 and nums[j] > v:
nums[j+1] = nums[j] #jにあった数をj+1(つまりi)に移す
j -= 1 #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,620 |
s464378024 | p02255 | u631142478 | 1554383143 | Python | Python3 | py | Accepted | 20 | 5596 | 251 | n = int(input())
a = list(map(int, input().split()))
print(' '.join(map(str, a)))
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j + 1] = v
print(' '.join(map(str, a)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,621 |
s133796013 | p02255 | u575962166 | 1554357468 | Python | Python3 | py | Accepted | 20 | 5596 | 343 | 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):
if a[i] > a[i-j-1]:
temp = a.pop(i)
a.insert(i-j,temp)
break
elif j == i - 1:
temp = a.pop(i)
a.insert(0,temp)
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,622 |
s153641001 | p02255 | u834458982 | 1554243532 | Python | Python3 | py | Accepted | 20 | 5600 | 258 | a = int(input())
b = list(map(int,input().split()))
print(" ".join(list(map(str,b))))
for i in range(1,a):
v = b[i]
j = i -1
while j >=0 and b[j] > v:
b[j+1] = b[j]
j -= 1
b[j+1] = v
print(" ".join(list(map(str,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,623 |
s977070101 | p02255 | u420297678 | 1554127784 | Python | Python3 | py | Accepted | 20 | 5600 | 381 | def show(nums):
print(" ".join(list(map(str, nums))))
def insertion_sort(nums):
show(nums)
for i in range(1, len(nums)):
v = nums[i]
j = i - 1
while j >= 0 and nums[j] > v:
nums[j + 1] = nums[j]
j -= 1
nums[j + 1] = v
show(nums)
N = int(inp... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,624 |
s751511059 | p02255 | u463563798 | 1553942671 | Python | Python3 | py | Accepted | 40 | 6320 | 445 | def pr(A):
N = len(A);
for i in range(N):
if i :
print (" ", end = "");
print (A[i], end = "")
print ("")
def insertionSort(A):
pr(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]
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,625 |
s458567669 | p02255 | u247705495 | 1553915329 | Python | Python3 | py | Accepted | 20 | 5984 | 313 | N = int(input())
Line_A = list(map(int, input().split()))
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)
insertionSort(Line_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,626 |
s438680114 | p02255 | u037765378 | 1553827708 | Python | Python3 | py | Accepted | 20 | 5980 | 293 | N = int(input())
A = list(map(int, input().split()))
def insec_sort(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)
insec_sort(A,N)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,627 |
s510474920 | p02255 | u190602799 | 1553752136 | Python | Python3 | py | Accepted | 20 | 5604 | 369 | N = int(input())
A = input().split()
print(' '.join(A))
A = [int(s) for s in A]
while A != sorted(A):
for i in range(1, N):
tmp = A[i]
if A[i-1] > tmp:
j = i
while j >0 and A[j-1] > tmp:
A[j] = A[j-1]
j -= 1
A[j] = tmp
resul... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,628 |
s631182395 | p02255 | u862923854 | 1553666716 | Python | Python3 | py | Accepted | 30 | 5980 | 425 | 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] > ... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,629 |
s749199736 | p02255 | u990228206 | 1553579345 | Python | Python3 | py | Accepted | 20 | 5632 | 240 | import bisect
n=int(input())
a=list(map(int,input().split()))
print(' '.join(map(str,a)))
for i in range(1,n):
a_n=a.pop(i)
insert_index = bisect.bisect_left(a[:i],a_n)
a.insert(insert_index,a_n)
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,630 |
s739033143 | p02255 | u019011517 | 1553562775 | Python | Python3 | py | Accepted | 20 | 5608 | 349 | def insertionSort(A):
for i in range(1,len(A)):
print(" ".join([str(i) for i in 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
n = int(input())
a = [int(i) for i in input().split()]
insertionSort(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,631 |
s505670588 | p02255 | u967553879 | 1553512138 | Python | Python3 | py | Accepted | 20 | 5980 | 203 | 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,632 |
s914050864 | p02255 | u498462680 | 1553435868 | Python | Python3 | py | Accepted | 20 | 5604 | 244 | N = int(input())
A = [int(i) for i in input().split()]
for i in range(1,N):
v = A[i]
j = i -1
print(' '.join(map(str,A)))
while j >=0 and A[j] > v:
A[j+1] = A[j]
A[j] = v
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,633 |
s319762551 | p02255 | u824216249 | 1553332472 | Python | Python3 | py | Accepted | 30 | 5980 | 430 | N = int(input())
nums = list(map(int, input().split()))
for i in range(N):
if i!=N-1:
print(nums[i],end=' ')
else:
print(nums[i])
for i in range(1,N):
key = nums[i]
j =i-1
while j >= 0 and nums[j] > key:
nums[j+1] = nums[j]
j-=1
nums[j+1] = key
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,634 |
s652101900 | p02255 | u356827208 | 1553282772 | Python | Python3 | py | Accepted | 20 | 5608 | 334 | def readInt():
return int(input())
def readInts():
return [int(i) for i in input().split()]
N = readInt()
AS = readInts()
print(' '.join([str(i) for i in AS]))
for i, a in enumerate(AS[1:]):
while i >= 0 and AS[i] > a:
AS[i + 1] = AS[i]
i -= 1
AS[i + 1] = a
print(' '.join([str(i) fo... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,635 |
s267293012 | p02255 | u922981423 | 1553255224 | Python | Python3 | py | Accepted | 20 | 5596 | 264 | n = int(input())
a = list(map(int,input().split()))
b = map(str, a)
print(' '.join(b))
for i in range(1, n):
v = a[i]
j = i - 1
while j >= 0 and a[j] > v:
a[j + 1] = a[j]
j -= 1
a[j+1] = v
b = map(str, a)
print(' '.join(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,636 |
s730328558 | p02255 | u799595944 | 1553088647 | Python | Python3 | py | Accepted | 20 | 5600 | 375 | def solution(count,nums):
for i in range(count):
objNum = nums[i]
j = i - 1
while j >= 0 and nums[j] > objNum:
nums[j+1] = nums[j]
j -= 1
nums[j+1] = objNum
print(' '.join(map(str,nums)))
count = int(input())
tmp = input().split(" ")
nums = []
for 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,637 |
s505237929 | p02255 | u148535395 | 1553003132 | Python | Python3 | py | Accepted | 20 | 5976 | 207 | 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,638 |
s903402222 | p02255 | u065504661 | 1552961366 | Python | Python3 | py | Accepted | 20 | 5604 | 365 | def insertion_sort(A):
global N
for i in range(1, N):
key = A[i]
j = i - 1
while A[j] > key and j >= 0:
A[j+1] = A[j]
j -= 1
A[j+1] = key
print(' '.join(list(map(str, A))))
return
N = int(input())
A = list(map(int, 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
| 31,639 |
s395751763 | p02255 | u621676340 | 1552653810 | Python | Python3 | py | Accepted | 20 | 5976 | 177 | n,*a=map(int,open(0).read().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,640 |
s581420276 | p02255 | u062898953 | 1552636101 | Python | Python3 | py | Accepted | 30 | 5608 | 231 | n = int(input())
*v, = map(int, input().split())
v = v[:n]
for i in range(n):
k = v[i]
j = i-1
while j >= 0 and v[j] > k:
v[j+1] = v[j]
j -= 1
v[j+1] = k
print(" ".join([str(_v) for _v in 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,641 |
s562472241 | p02255 | u756583088 | 1552383125 | Python | Python3 | py | Accepted | 20 | 5612 | 462 | import sys
n = int(input())
nums = [int(num) for num in input().split(" ")]
if n == 1:
print(nums[0])
else:
for i in range(0, n):
v = nums[i]
j = i - 1
while j >= 0 and v < nums[j]:
nums[j+1] = nums[j]
j -= 1
nums[j+1] = v
result = ""
fo... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,642 |
s166480822 | p02255 | u520843104 | 1552309769 | Python | Python3 | py | Accepted | 20 | 5604 | 329 | 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)))
N = int(input())
A = list(map(int, input().split() ))
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,643 |
s525087091 | p02255 | u815373012 | 1552130455 | Python | Python3 | py | Accepted | 20 | 5600 | 240 | Num_factor = int(input())
N = list(map(int, input().split()))
for i in range(int(Num_factor)):
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(map(str,N)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,644 |
s264333577 | p02255 | u009332121 | 1552093599 | Python | Python3 | py | Accepted | 30 | 5980 | 359 | length = int(input())
raw_list = input().split()
for i in range(length):
raw_list[i] = int(raw_list[i])
for i in range(length):
key = raw_list[i]
j = i - 1
while j >= 0 and raw_list[j] > key:
raw_list[j+1] = raw_list[j]
j -= 1
raw_list[j+1] = key
for k in range(length):
if k-length+1:
print(raw_list[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,645 |
s776669533 | p02255 | u888548672 | 1552058507 | Python | Python3 | py | Accepted | 20 | 5612 | 274 | def Show():
print(' '.join([str(aa) for aa in a]))
n = int(input())
a = list(map(int, input().split()))
Show()
for i in range(1, n):
target = a[i]
j = i-1
while j >= 0 and a[j] > target:
a[j+1] = a[j]
j -= 1
a[j+1] = target
Show()
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,646 |
s160700019 | p02255 | u327242612 | 1552033027 | Python | Python3 | py | Accepted | 20 | 5600 | 333 | 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(list(map(str, a))))
n = int(input())
a = list(map(int, input().split()))
print(' '.join(list(map(str, a))))
inserti... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,647 |
s159164018 | p02255 | u687450887 | 1552013049 | Python | Python3 | py | Accepted | 40 | 6308 | 525 | N = int(input())
A = list(map(int, input().split()))
for h in range(len(A)):
if h == len(A)-1:
print(A[h])
else:
print(A[h], "", end="")
def insertionSort(A, N):
for i in range(1, N):
temp = A[i]
j = i -1
while j >= 0 and temp < A[j]:
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,648 |
s637304044 | p02255 | u461909590 | 1551715077 | Python | Python3 | py | Accepted | 20 | 5976 | 193 | n = int(input())
x = list(map(int, input().split()))
for i in range(n):
v = x[i]
j = i-1
while j >=0 and x[j]>v:
x[j+1] = x[j]
j = j-1
x[j+1] = v
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,649 |
s195001940 | p02255 | u655589806 | 1551699276 | Python | Python3 | py | Accepted | 20 | 5972 | 238 | n = int(input())
cards = list(map(int,input().split()))
print(*cards)
for i in range(1,n):
v = cards[i]
j = i-1
while j >= 0 and cards[j] > v:
cards[j+1] = cards[j]
j -= 1
cards[j+1] = v
print(*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,650 |
s518202741 | p02255 | u805716376 | 1551696136 | Python | Python3 | py | Accepted | 20 | 5972 | 193 | n = int(input())
r = list(map(int,input().split()))
for i in range(n):
value = r[i]
while i >= 1 and r[i-1] > value:
r[i] = r[i-1]
i -= 1
r[i] = value
print(*r)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,651 |
s650452617 | p02255 | u306715188 | 1551612660 | Python | Python3 | py | Accepted | 20 | 5600 | 248 | N = int(input())
A = list(map(int,input().split()))
for i in range(1,N) :
print (" ".join(map(str, A)))
v = A[i]
j = i - 1
while j >= 0 and A[j] > v :
A[j+1] = A[j]
j -= 1
A[j+1] = v
print (" ".join(map(str,A)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,652 |
s861311699 | p02255 | u811314383 | 1550825223 | Python | Python3 | py | Accepted | 30 | 5984 | 475 | def pres(data, N):
for i in range(N):
if i < N-1:
print('%d '%data[i], end='')
else:
print(data[i])
def ins_sort(data, N):
for i in range(1, N):
flag = data[i]
j = i-1
while j>=0 and data[j]>flag:
data[j+1] = data[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,653 |
s497671864 | p02255 | u058202717 | 1550388887 | Python | Python | py | Accepted | 10 | 4668 | 471 | 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 = j - 1
A[j + 1] = v
print(' '.join(map(lambda x: str(x), A)))
return A
N = input()
while True:
try:
line = raw_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,654 |
s731821930 | p02255 | u682205001 | 1550378463 | Python | Python3 | py | Accepted | 20 | 5612 | 298 | N = int(input()) #number of elements
seq = list(map(int,input().split()))
print(' '.join([str(i) for i in 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([str(k) for k in 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
| 31,655 |
s204836131 | p02255 | u276288047 | 1550043807 | Python | Python3 | py | Accepted | 40 | 6324 | 494 | # coding: utf-8
def printA(a, n):
for i in range(n):
print(a[i],end="")
if i < n - 1:
print(" ", end="")
else:
print()
def insertionSort(a, n):
printA(ai, 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,656 |
s586530580 | p02255 | u645790535 | 1549842102 | Python | Python3 | py | Accepted | 20 | 5980 | 362 | def trace(A: list):
print(*A)
def insertionSort(A: list, N:int) -> list:
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and v < A[j]:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
trace(A)
return A
N = int(input())
A = list(map(int, input().sp... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,657 |
s408178787 | p02255 | u088337682 | 1549787670 | Python | Python3 | py | Accepted | 30 | 5980 | 343 | 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())
A = list(map(int,input().split()))
show(A)
for i in range(1,N):
v = A[i]
while i - 1 >= 0 and A[i-1] > v:
A[i] = A[i-1]
i -= 1
... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,658 |
s852718509 | p02255 | u353819610 | 1549760119 | Python | Python3 | py | Accepted | 50 | 5980 | 573 | # http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A&lang=jp
def insertion_sort(array):
putsarray(array)
N = len(array)
for i in range(1, N):
j = i - 1
num = array[i]
while j >= 0 and array[j] > num:
array[j + 1] = array[j]
j -= 1
arra... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,659 |
s396682358 | p02255 | u394181453 | 1549633132 | Python | Python3 | py | Accepted | 20 | 5596 | 272 | n = int(input())
nums = list(map(int, input().split()))
print(' '.join(map(str, 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]
j -= 1
nums[j+1] = v
print(' '.join(map(str, nums)))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,660 |
s671737849 | p02255 | u564898184 | 1549625724 | Python | Python3 | py | Accepted | 20 | 5596 | 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=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,661 |
s704042340 | p02255 | u767794720 | 1549528939 | Python | Python3 | py | Accepted | 20 | 5600 | 244 | 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,662 |
s795690706 | p02255 | u483930210 | 1549506188 | Python | Python3 | py | Accepted | 20 | 5608 | 238 | n = int(input())
a = list(map(int, input().split()))
for i in range(n):
for j in range(1, n):
if i-j >= 0 and a[i-j] > a[i-j+1]:
a[i-j], a[i-j+1] = a[i-j+1], a[i-j]
else:
break
print(" ".join([str(i) for i 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,663 |
s153647450 | p02255 | u263141957 | 1549439957 | Python | Python3 | py | Accepted | 30 | 5980 | 413 | N = int(input())
A = [int(i) for i in input().split()]
def ins(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
for k in range(N):
if k == N - 1:
print(A[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
| 31,664 |
s338217915 | p02255 | u863404197 | 1549350979 | Python | Python3 | py | Accepted | 20 | 5996 | 582 | def insertionSort(A, N):
'''list of int, int(=len(A)) -> list of int
return sorted list(insertion sort)
'''
l = N
outA = A.copy()
for i in range(l):
val = outA[i]
j = i - 1
while j >= 0 and outA[j] > val:
outA[j + 1] = outA[j]
j -= 1
outA[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,665 |
s805510541 | p02255 | u977532918 | 1549166551 | Python | Python3 | py | Accepted | 20 | 5600 | 338 | num = int(input())
A = list(map(int, input().split()))
tempA = map(str, A)
print(' '.join(tempA))
for i in range(1, num):
temp = A[i]
j = i - 1
while j >= 0 and A[j] > temp:
A[j + 1] = A[j]
j -= 1
A[j + 1] = temp
tempA = map(str, A)
print... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,666 |
s082662848 | p02255 | u759934006 | 1549091569 | Python | Python3 | py | Accepted | 20 | 5604 | 352 | def insertion_sort(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([str(x) for x in A]))
n = int(input())
A = [int(x) for x in input().split()]
print(' '.join([str(x) fo... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,667 |
s316072127 | p02255 | u498511622 | 1549084161 | Python | Python3 | py | Accepted | 20 | 5980 | 280 | def insert(A,N):
for i in range(1,N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(*A)
N = int(input())
A = list(map(int,input().split()))
print(*A)
insert(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,668 |
s070293696 | p02255 | u777070060 | 1549001856 | Python | Python3 | py | Accepted | 20 | 5976 | 154 | input();a=list(map(int,input().split()));print(*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(*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,669 |
s296251878 | p02255 | u247475019 | 1548922155 | Python | Python3 | py | Accepted | 20 | 5608 | 447 |
def printArrLine( arr ):
print(' '.join(list(map(str,arr))))
def inputArrLine():
return [int(i) for i in input().split()]
def insert( arr ):
n = len(arr)
printArrLine(arr)
for i in range(1,n):
v = arr[i]
j = i-1
while j >= 0 and arr[j] > v:
arr[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,670 |
s843257060 | p02255 | u752764084 | 1548860544 | Python | Python3 | py | Accepted | 20 | 5604 | 259 | def insertionSort(L, n):
for i in range(n):
v = L[i]
j = i - 1
while j >= 0 and L[j] > v:
L[j+1] = L[j]
j -= 1
L[j+1] = v
print(' '.join(map(str, L)))
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,671 |
s111890191 | p02255 | u797780263 | 1548554686 | Python | Python3 | py | Accepted | 20 | 5980 | 214 | n = int(input())
A = list(map(int, input().split()))
print(*A)
for i in range(1, n):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j + 1] = A[j]
j -= 1
A[j + 1] = v
print(*A)
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,672 |
s728004402 | p02255 | u597769560 | 1548506673 | Python | Python3 | py | Accepted | 20 | 5612 | 343 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 26 21:11:25 2019
@author: Yamazaki Kenichi
"""
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(' '.... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,673 |
s505784618 | p02255 | u286092058 | 1548491148 | Python | Python3 | py | Accepted | 20 | 5596 | 319 | N = int(input())
I = list(map(int, input().split()))
print(str(I).replace(',','').replace('[','').replace(']',''))
for i in range(1, N):
v = I[i]
j = i - 1
while (j >= 0 and I[j] > v):
I[j+1] = I[j]
j -= 1
I[j+1] = v
print(str(I).replace(',','').replace('[','').replace(']',''))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,674 |
s232916622 | p02255 | u806005289 | 1548049537 | Python | Python3 | py | Accepted | 20 | 5604 | 253 | n = int(input())
A = list(map(int, input().split()))
i=1
print(" ".join(list(map(str, A))))
while i < n:
v = A[i]
j = i-1
while j >= 0 and A[j]>v:
A[j+1]=A[j]
j-=1
A[j+1]=v
print(" ".join(list(map(str,A))))
i+=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,675 |
s506226066 | p02255 | u643542669 | 1547804385 | Python | Python3 | py | Accepted | 20 | 5600 | 375 | n = int(input())
a = input().split()
print(" ".join(a))
a1 = [a[0]]
a2 = a[1:]
for _ in range(n - 1):
for j, k in enumerate(a1):
if int(a2[0]) < int(k):
if j == 0:
a1.insert(0, a2[0])
else:
a1.insert(j, a2[0])
break
else:
a1.app... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,676 |
s490998540 | p02255 | u550922601 | 1547519006 | Python | Python3 | py | Accepted | 20 | 5976 | 234 | #挿入ソート
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,677 |
s950147334 | p02255 | u366342113 | 1547475547 | Python | Python3 | py | Accepted | 20 | 5600 | 260 | N = int(input())
A = list(map(int, input().split()))
print(" ".join(list(map(str, A))))
for i in range(1, N):
v = A[i]
j = i - 1
while j >= 0 and A[j] > v:
A[j+1] = A[j]
j -= 1
A[j+1] = v
print(" ".join(list(map(str, A))))
| p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,678 |
s241618283 | p02255 | u739297462 | 1546949051 | Python | Python3 | py | Accepted | 30 | 5980 | 700 | def show(list1):
for i in range(len(list1)):
if i<len(list1)-1:
print(list1[i],end=' ')
else:
print(list1[i]) # print() 默认以回车作为输入结束符
n = int(input()) # input()从标准输入读入一行文本
list1 = list(map(int,input().split())) # str.split() 切割字符串返回list类型
# map(f,list) 将函数f作用用list的每个元素,返回map类型,用list() 强制类型转... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,679 |
s487943588 | p02255 | u350155409 | 1546587491 | Python | Python3 | py | Accepted | 20 | 5980 | 359 | def insertion_sort(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 = j-1
a[j+1] = key
print(*a,sep=' ')
return a
if __name__ == '__main__':
n = input()
a = list(map(int,input().split()))
p... | p02255 |
<H1>Insertion Sort</H1>
<p>
Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode:
</p>
<pre>
for i = 1 to A.length-1
key = A[i]
/* insert A[i] into the sorted sequence A[0,...,j-1] */
j = i - 1
while j >... | 6
5 2 4 6 1 3
| 5 2 4 6 1 3
2 5 4 6 1 3
2 4 5 6 1 3
2 4 5 6 1 3
1 2 4 5 6 3
1 2 3 4 5 6
| 31,680 |
s638738554 | p02255 | u771410206 | 1545121637 | Python | Python3 | py | Accepted | 20 | 5596 | 245 | 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 v < A[j]:
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,681 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.