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
s219475182
p02255
u525366883
1535087304
Python
Python
py
Accepted
10
4640
244
n = int(raw_input()) a = map(int, raw_input().split()) print " ".join(map(str, a)) for i in range(1, n): v = a[i] j = i -1 while j >= 0 and a[j] > v: a[j+1] = a[j] j-=1 a[j+1] = v print " ".join(map(str, a))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,482
s233962332
p02255
u751769081
1535343714
Python
Python3
py
Accepted
30
5976
284
def insert_sort(A, N): for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v; print(*A) N = int(input()) A = [int(n) for n in input().split()]; print(*A) insert_sort(A, N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,483
s709917133
p02255
u427752990
1535344814
Python
Python3
py
Accepted
30
5980
569
# inputList = list(map(int, '''6 # 5 2 4 6 1 3'''.split())) # N = inputList.pop(0) def formatting(nums): for i in range(len(nums)): if i != len(nums) - 1: print(nums[i], end=' ') else: print(nums[i]) def insertionSort(A, N): for i in range(1, N): v = 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
30,484
s404518021
p02255
u418996726
1535419039
Python
Python3
py
Accepted
20
5596
308
input() myarr = list(map(int, input().split())) for i in range(len(myarr)): for j in range(i, 0,-1): if myarr[j] < myarr[j-1]: t = myarr[j] myarr[j] = myarr[j-1] myarr[j-1] = t else: break print(" ".join(map(str, myarr)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,485
s526005471
p02255
u928491417
1535424331
Python
Python3
py
Accepted
30
5984
454
# 配列の要素数 num = int(input()) # 配列 array = list(map(int, input().split())) def print_array(): for i in range(num): if i != num-1: print(array[i], end=' ') else: print(array[i]) # insertion sort for i in range(num): insert = array[i] j = 0 while array[j] < insert...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,486
s004526907
p02255
u462873421
1535526287
Python
Python
py
Accepted
10
4644
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,487
s097834663
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4648
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,488
s999609553
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4644
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,489
s606671641
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4648
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,490
s658648173
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4648
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,491
s740646496
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4648
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,492
s941219049
p02255
u462873421
1535526288
Python
Python
py
Accepted
10
4644
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,493
s747326154
p02255
u462873421
1535526289
Python
Python
py
Accepted
10
4648
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,494
s096929487
p02255
u462873421
1535526289
Python
Python
py
Accepted
10
4644
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,495
s317266495
p02255
u462873421
1535526310
Python
Python
py
Accepted
10
4644
296
num=int(raw_input().strip()) lst=map(int,raw_input().strip().split()) def sort(lst,idx): tmp=lst[idx] idx-=1 while idx>=0 and lst[idx]>tmp: lst[idx+1]=lst[idx] idx-=1 lst[idx+1]=tmp for ii in xrange(num): sort(lst,ii) print " ".join(str(i) for i in lst)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,496
s204454681
p02255
u665238221
1535535613
Python
Python3
py
Accepted
20
5984
349
def insertion_sort(A, N): yield 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 yield A N = int(input()) A = list(map(int, input().split())) for li in insertion_sort(A, ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,497
s678006028
p02255
u317583692
1535616357
Python
Python3
py
Accepted
30
5592
419
N = int(input()) A = list(map(int, input().split())) for i in range(N): if N == 1: print(A[0]) break j = i while j > 0 and A[j] < A[j-1]: if A[j] > A[j-1]: break k = A[j] l = A[j-1] A[j-1] = k A[j] = l j -= 1 S = str(A[0]) ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,498
s453973086
p02255
u518159956
1535698548
Python
Python3
py
Accepted
20
5596
262
N=int(input()) a=list(map(int, input().split())) k=list(map(str,a)) j=' '.join(k) print(j) for i in range(1,N): v=a[i] j=i-1 while a[j]>v and j>=0: a[j+1]=a[j] j -=1 a[j+1]=v b=list(map(str, a)) c=' '.join(b) print(c)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,499
s092589354
p02255
u153772872
1535970622
Python
Python3
py
Accepted
30
5980
363
def show (nums): for i in range(len(nums)): if i!=len(nums)-1: print(nums[i],end=' ') else : print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[j] ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,500
s003760080
p02255
u744506422
1540293559
Python
Python3
py
Accepted
20
5604
333
N=int(input()) A=[int(i) for i in input().split()] S="" for i in range(N-1): S=S+str(A[i])+" " S=S+str(A[N-1]) print(S) 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 S="" for i in range(N-1): S=S+str(A[i])+" " S=S+str(A[N-1]) ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,501
s455805644
p02255
u653404153
1540350917
Python
Python3
py
Accepted
20
5600
466
def insertionSort(a, n): trace(a, n) for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v trace(a, n) def trace(a, n): output = '' for i in a: if i == a[n-1]: output += 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
30,502
s173279072
p02255
u418996726
1540716097
Python
Python3
py
Accepted
20
5600
322
def insertion_sort(arr): print(" ".join(map(str, arr))) for i in range(1,len(arr)): j = i while arr[j] < arr[j-1] and j > 0: arr[j-1], arr[j] = arr[j], arr[j-1] j -= 1 print(" ".join(map(str, arr))) input() arr = list(map(int, input().split())) insertion_sort(arr...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,503
s731142660
p02255
u350064373
1540789191
Python
Python3
py
Accepted
20
5984
351
def main(): N = int(input()) A = list(map(int,input().split())) insertionSort(A, N) 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) 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
30,504
s993355018
p02255
u125481461
1540850937
Python
Python3
py
Accepted
20
5604
377
def main(): _ = input() array = [int(x) for x in input().split()] print(" ".join(map(str, array))) for i in range(1, len(array)): moving = array[i] j = i - 1 while j >= 0 and moving < array[j]: array[j+1] = array[j] j -= 1 array[j+1] = moving ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,505
s819021100
p02255
u901205536
1541079739
Python
Python3
py
Accepted
30
5984
333
N = int(input()) A = list(map(int, input().split(" "))) for k in range(len(A)-1): print(A[k], end= " ") print(A[-1]) for i in range(1, N): v = A[i] j = i-1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v for k in range(len(A)-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
30,506
s916434702
p02255
u222257547
1541090570
Python
Python3
py
Accepted
20
5980
397
def showList(A, N): for i in range(N-1): print(A[i],end=' ') print(A[N-1]) def insertionSort(A, N): showList(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 showList(A,N) N = 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
30,507
s196350000
p02255
u209940149
1541148242
Python
Python3
py
Accepted
20
5984
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
30,508
s686910988
p02255
u064313887
1545589169
Python
Python3
py
Accepted
30
5976
456
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 show(A) def show(nums): for i in range(len(nums)): if i != len(nums) - 1: print(nums[i],en...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,509
s139134619
p02255
u581154076
1546167317
Python
Python3
py
Accepted
20
5600
337
n = int(input()) a = [int(i) for i in input().split()] def trace(a): a = map(str, a) print(' '.join(a)) def insertion(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 trace(a) trace...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,510
s931192312
p02255
u453928244
1546171997
Python
Python3
py
Accepted
20
5596
259
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 ans = ' '.join(map(str,a)) print(ans)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,511
s675282725
p02255
u809233245
1546223069
Python
Python3
py
Accepted
20
5592
250
n = int(input()) a = list(map(int, 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] j -= 1 a[j+1] = v print(' '.join(map(str, a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,512
s464240182
p02255
u874395007
1546397206
Python
Python3
py
Accepted
20
5604
299
def out(data) -> str: print(' '.join(map(str, data))) N = int(input()) data = [int(i) for i in input().split()] out(data) for i in range(1, N): tmp = data[i] j = i - 1 while j >= 0 and data[j] > tmp: data[j + 1] = data[j] j -= 1 data[j + 1] = tmp out(data)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,513
s535069663
p02255
u908238078
1546409998
Python
Python3
py
Accepted
20
5596
357
N = int(input().rstrip()) A = list(map(int, input().rstrip().split())) def insertion_sort(A, N): for i in range(N): key = A[i] j = i - 1 while j >= 0 and A[j] > key: A[j+1] = A[j] j -= 1 A[j+1] = key string = list(map(str, A)) print(' '.join(...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,514
s481847958
p02255
u634490486
1546521954
Python
Python3
py
Accepted
20
5980
288
from sys import stdin n = int(stdin.readline().rstrip()) A = [int(x) for x in stdin.readline().rstrip().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 = j-1 else: A[j+1] = v print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,515
s737718681
p02255
u452220492
1551274311
Python
Python3
py
Accepted
20
5608
259
n = int(input()) a = [int(i) for i in input().split()] print(" ".join([str(i) for i in a])) for i in range(1, n): j = i while a[j - 1] > a[j] and j > 0: a[j], a[j - 1] = a[j - 1], a[j] j -= 1 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
30,516
s803702303
p02255
u670433235
1551487929
Python
Python3
py
Accepted
20
5596
239
n=int(input()) a=list(map(int,input().split())) print(" ".join(map(str,a))) for i in range(1,n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(" ".join(map(str,a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,517
s695144014
p02255
u232404920
1551528573
Python
Python3
py
Accepted
20
5600
252
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
30,518
s082695508
p02255
u698762975
1555657307
Python
Python3
py
Accepted
20
5600
251
def inserrtionsort(l,n): for i in range(1,n): print(" ".join(l)) v=l[i] j=i-1 while int(v)<int(l[j]) and j>=0: l[j+1]=l[j] j-=1 l[j+1]=v print(" ".join(l)) m=int(input()) n=list(input().split()) inserrtionsort(n,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
30,519
s808383206
p02255
u078616159
1555834946
Python
Python3
py
Accepted
20
5976
275
n = int(input()) data = input().split() array = [] for i in data: array.append(int(i)) for i in range(1, n): print(*array) key = array[i] j = i - 1 while j >= 0 and array[j] > key: array[j+1] = array[j] j -= 1 array[j+1] = key print(*array)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,520
s294540779
p02255
u127167915
1555837745
Python
Python3
py
Accepted
20
5980
465
# -*- Coding: utf-8 -*- def trace(A, N): for i in range(int(N)-1): print(A[i], end=' ') print(A[int(N)-1]) def insertionSort(A, N): for i in range(1, int(N)): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,521
s585236754
p02255
u621090425
1555852242
Python
Python3
py
Accepted
20
5980
209
N = int(input()) A = list(map(int,input().split())) print(*A) for i in range(1,N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(*A)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,522
s562840371
p02255
u870370075
1556249181
Python
Python3
py
Accepted
20
5596
221
n=int(input()) arr=list(map(int,input().split())) print(' '.join(map(str,arr))) for i in range(1,n): v=arr[i] j=i-1 while j>=0 and arr[j]>v: arr[j+1]=arr[j] j-=1 arr[j+1]=v print(' '.join(map(str,arr)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,523
s818104819
p02255
u197615397
1556372464
Python
Python3
py
Accepted
20
5980
184
n = int(input()) a = list(map(int, input().split())) for i in range(n): j = i while j >= 1 and a[j-1] > a[j]: a[j-1], a[j] = a[j], a[j-1] j -= 1 print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,524
s100425878
p02255
u548252256
1556416329
Python
Python3
py
Accepted
20
5604
232
num = int(input()) A = list(map(int,input().split(" "))) for i in range(num): v = A[i] j = i -1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v #出力用 list2 = [str(k) for k in A] print(" ".join(list2))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,525
s030942077
p02255
u599879983
1556599168
Python
Python3
py
Accepted
20
5604
372
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 outputNum(A) def outputNum(A): tmp = map(str,A) text = " ".join(tmp...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,526
s163345638
p02255
u065009908
1556609128
Python
Python3
py
Accepted
20
5600
224
n=int(input()) a=list(map(int,input().split())) print(' '.join(map(str,a))) for i in range(1,n): v=a[i] j=i-1 while j>=0 and a[j]>v: a[j+1]=a[j] j-=1 a[j+1]=v print(' '.join(map(str,a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,527
s193337742
p02255
u088264506
1556619229
Python
Python3
py
Accepted
20
5600
434
n = int(input()) l = list(map(int, input().split())) print(" ".join(map(str,l))) def insertionSort(a, n):#配列aを挿入ソートで並び替える(昇順) for i in range(1,n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j]#a[i]の位置に詰めていく処理 j -= 1 a[j+1] = v print(" ".j...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,528
s740322683
p02255
u083560765
1556709741
Python
Python3
py
Accepted
20
5604
175
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(list(map(str,a))))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,529
s918448457
p02255
u482227082
1558933679
Python
Python3
py
Accepted
20
5980
308
def main(): N = int(input()) L = list(map(int, input().split())) for i in range(1, N): print(*L) tmp = L[i] j = i while j > 0 and L[j-1] > tmp: L[j] = L[j-1] j -= 1 L[j] = tmp print(*L) if __name__ == '__main__': main()
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,530
s928535554
p02255
u852112234
1558942949
Python
Python3
py
Accepted
30
5984
415
N = int(input()) A = list(map(int,input().split())) def 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 pr(A) def pr(list): n = len(list) for i in range(n): if i < n-1: ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,531
s591140837
p02255
u552802136
1558967689
Python
Python3
py
Accepted
20
5604
319
def insertionSort(S, N): for i in range(N): v = S[i] j = i-1 while j >= 0 and S[j] > v: S[j+1] = S[j] j = j-1 S[j+1] = v print(' '.join(map(str, S))) n = int(input()) s = list(map(int, input().split())) insertionSort(s, n)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,532
s314422147
p02255
u662822413
1559052926
Python
Python3
py
Accepted
30
5984
366
def show(nums): for i in range(len(nums)): if i !=len(nums)-1: print(nums[i],end=' ') else: print(nums[i]) n=int(input()) nums=list(map(int,input().split())) show(nums) for i in range(1,n): v=nums[i] j=i-1 while (j>=0 and nums[j]>v): nums[j+1]=nums[j] ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,533
s917588923
p02255
u764759179
1559091728
Python
Python3
py
Accepted
20
5604
430
# coding:utf-8 def printline(data): l="" for i,s in enumerate(data): l = l + str(s) if i+1 != len(data): l = l+" " print(l) length = int(input()) data = list(map(int,input().split())) printline(data) for i in range(1,len(data)): tmp = data[i] i2 = i - 1 while i2 >=...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,534
s095234534
p02255
u849117723
1559123191
Python
Python3
py
Accepted
20
5976
197
n=int(input()) ls=list(map(int,input().split())) print(*ls) for i in range(1,n): v=ls[i] j=i-1 while j>=0 and ls[j]>v: ls[j+1]=ls[j] j-=1 ls[j+1]=v print(*ls)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,535
s121370605
p02255
u357267874
1559173390
Python
Python3
py
Accepted
20
5980
389
def insertion_sort(A, N): for i in range(1, N): v = A[i] j = i - 1 # print('[start] i:', i, 'j:', j, 'v:', v) while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v # print('i:', i, 'v:', v, 'to:', j+1 ,A) print(*A) N = int(input()...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,536
s330994327
p02255
u135880652
1559361113
Python
Python3
py
Accepted
20
5596
249
N = int(input()) A = list(map(int, input().split())) print(' '.join(map(str, A))) for i in range(1, N): v = A[i] j = i - 1 while j >=0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,537
s128668126
p02255
u535719732
1559375618
Python
Python3
py
Accepted
20
5984
180
n = int(input()) a = list(map(int,input().split())) for i in range(1,n): print(*a) j = i -1 v = a[i] while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(*a)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,538
s619340090
p02255
u841945203
1559390799
Python
Python3
py
Accepted
20
5980
284
def insertionSort(A,N): 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=" ") N = int(input()) A = input().split() A = list(map(int,A)) insertionSort(A,N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,539
s330832057
p02255
u841945203
1559391125
Python
Python3
py
Accepted
20
5984
278
def insertionSort(A,N): 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=" ") N = int(input()) A = list(map(int,input().split())) insertionSort(A,N)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,540
s445269554
p02255
u108666393
1559404621
Python
Python3
py
Accepted
20
5980
404
def insertion_sort(A): n = len(A) print(*A) for i in range(1, n): item = A[i] cur_idx = i - 1 while cur_idx >= 0 and A[cur_idx] > item: A[cur_idx], A[cur_idx + 1] = A[cur_idx + 1], A[cur_idx] cur_idx -= 1 print(*A) if __name__ == "__main__": N = ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,541
s326513689
p02255
u319740114
1559468790
Python
Python3
py
Accepted
20
5596
249
N = int(input()) A = list(map(int, input().split())) print(" ".join(map(str,A))) for i in range(1,N): tmp = A[i] j = i-1 while j >= 0 and A[j] > tmp: A[j+1] = A[j] j += -1 A[j+1] = tmp print(" ".join(map(str,A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,542
s346221423
p02255
u193025715
1408608447
Python
Python3
py
Accepted
30
6724
250
n = int(input()) nums = list(map(int, input().split())) for i in range(len(nums)): key = nums[i] j = i - 1 while j >= 0 and nums[j] > key: nums[j+1] = nums[j] j -= 1 nums[j+1] = key print(' '.join(map(str, nums)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,543
s547818164
p02255
u379499530
1415022780
Python
Python
py
Accepted
10
4228
417
def main(): number = int(raw_input()) list = map(int, raw_input().split()) sort(number, list) def sort(number, list): output(list) for i in range(1, number): key = list[i] j = i - 1 while j >= 0 and list[j] > key: list[j+1] = list[j] j -= 1 li...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,544
s066206044
p02255
u379499530
1415284003
Python
Python
py
Accepted
20
4212
218
n = input() a = map(int, raw_input().split()) for i in range(n): key = a[i] j = i - 1 while j >= 0 and a[j] > key: a[j + 1] = a[j] j -= 1 a[j + 1] = key print(" ".join(map(str, a)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,545
s968487428
p02255
u507118101
1417229668
Python
Python
py
Accepted
20
4236
336
N = input(); A = map(int,raw_input().split(" ")) for i in range(1,len(A)): key = A[i] j = i - 1; for k in range(0,len(A)): if A[N-1] == A[k]: print A[k] else: print A[k], while j >=0 and A[j] > key: A[j+1] = A[j] j -= 1 A[j+1] = key for j in range(0,len(A)): if A[N-1] == A[j] : print A[j] else...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,546
s984772120
p02255
u672822075
1418912529
Python
Python3
py
Accepted
40
6724
200
n = int(input()) lst = list(map(int, input().split())) for i in range(n): key = lst[i] j = i-1 while j>=0 and lst[j]>key: lst[j+1] = lst[j] j -= 1 lst[j+1] = key print(" ".join(map(str,lst)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,547
s116381415
p02255
u481221703
1419463179
Python
Python
py
Accepted
20
4204
228
n = raw_input() A = map(int, raw_input().split()) for i, key in enumerate(A): j = i - 1 while(j >= 0 and A[j] > key): A[j+1] = A[j] j -= 1 A[j+1] = key for x in A: print x, print
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,548
s599080589
p02255
u580607517
1420371859
Python
Python
py
Accepted
20
4224
277
import sys N = int(raw_input()) A = map(int, raw_input().split()) a_str = map(str, A) print(" ".join(a_str)) 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 a_str = map(str, 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
30,549
s222528180
p02255
u567380442
1421238633
Python
Python3
py
Accepted
40
6756
214
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
30,550
s051631019
p02255
u813534019
1422124495
Python
Python
py
Accepted
20
4232
358
n=input() num_list=[int(x) for x in raw_input().split(" ")] for idx in range(1, len(num_list)): print " ".join([str(x) for x in num_list]) key=num_list[idx] jdx = idx - 1 while jdx >= 0 and num_list[jdx] > key: num_list[jdx+1] = num_list[jdx] jdx -= 1 num_list[jdx+1] = key prin...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,551
s071060582
p02255
u879226672
1425008102
Python
Python
py
Accepted
20
4220
241
N = int(raw_input()) A = map(int,raw_input().split()) print ' '.join(map(str,A)) for i in range(1,N): v = A[i] j = i - 1 while j >=0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print ' '.join(map(str,A))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,552
s778854355
p02255
u370429022
1426610602
Python
Python3
py
Accepted
40
6756
337
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 = j-1 A[j+1] = v print(*A) if __name__ == '__main__': N = int(input()) A = [int(_) for _ in input().split()] print(*A) ins...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,553
s424005351
p02255
u333544617
1426674653
Python
Python
py
Accepted
20
4220
317
#! /usr/bin/python if __name__ == "__main__": n = int(raw_input()) array = map(int, raw_input().split()) for i in range(1, n): print " ".join(map(str, array)) key = array[i] j = i - 1 while j >= 0 and array[j] > key: array[j+1] = array[j] j -= 1 array[j+1] = key print " ".join(map(str, array))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,554
s934110288
p02255
u128811851
1429630440
Python
Python3
py
Accepted
40
6756
544
def insertionSort(array, amount): for i in range(1, amount): v = array[i] j = i - 1 while j >= 0 and array[j] > v: array[j + 1] = array[j] j = j - 1 array[j + 1] = v for i in range(amount - 1): print(array[i], end=" ") print(array...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,555
s854730137
p02255
u140201022
1431625039
Python
Python
py
Accepted
20
4668
578
#!/usr/bin/env python # -*- coding: UTF-8 -*- import time import sys import io import re import math import itertools #sys.stdin=file('input.txt') #sys.stdout=file('output.txt','w') #10**9+7 mod=1000000007 #mod=1777777777 pi=3.141592653589 xy=[(1,0),(-1,0),(0,1),(0,-1)] bs=[(-1,-1),(-1,1),(1,1),(1,-1)] #start = time.cl...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,556
s575783793
p02255
u949338836
1431948344
Python
Python3
py
Accepted
40
6756
278
#coding:utf-8 n = int(input()) numbers = list(map(int,input().split())) print(*numbers) for i in range(1,n): tmp = numbers[i] j = i - 1 while j >= 0 and numbers[j] > tmp: numbers[j+1] = numbers[j] j -= 1 numbers[j+1] = tmp print(*numbers)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,557
s318834997
p02255
u949338836
1431948557
Python
Python3
py
Accepted
40
6752
259
#coding:utf-8 n = int(input()) numbers = list(map(int,input().split())) for i in range(n): tmp = numbers[i] j = i - 1 while j >= 0 and numbers[j] > tmp: numbers[j+1] = numbers[j] j -= 1 numbers[j+1] = tmp print(*numbers)
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,558
s897186180
p02255
u002380486
1432029814
Python
Python
py
Accepted
20
4212
238
N = input() A = map(int, raw_input().split()) for i in range(1,N): print " ".join(map(str, A)) v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print " ".join(map(str, A))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,559
s447431870
p02255
u689297737
1432044481
Python
Python
py
Accepted
20
4224
442
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A import sys nums_len = int(sys.stdin.readline()) nums_str = sys.stdin.readline().split(' ') nums = map(int, nums_str) print ' '.join(map(str, nums)) for i in range(1, nums_len): for j in reversed(range(1, i + 1)): if nums[j] < nums[j - 1]...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,560
s017540207
p02255
u689297737
1432045401
Python
Python
py
Accepted
20
4224
458
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_1_A import sys nums_len = int(sys.stdin.readline()) nums_str = sys.stdin.readline().split(' ') nums = map(int, nums_str) print ' '.join(map(str, nums)) for i in range(1, nums_len): v = nums[i] for j in reversed(range(0, i)): if v < nums[...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,561
s903499026
p02255
u604774382
1432446830
Python
Python
py
Accepted
20
4232
405
def trace( nums ): output = [] for num in nums: output.append( str( num ) ) output.append( " " ) output.pop( ) print( "".join( output ) ) n = int( raw_input( ) ) nums = [ int( val ) for val in raw_input( ).split( " " ) ] trace( nums ) for i in range( 1, len( nums ) ): key = nums[i] j = i - 1 while 0 <= j ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,562
s875656668
p02255
u604774382
1432446851
Python
Python3
py
Accepted
30
6724
397
def trace( nums ): output = [] for num in nums: output.append( str( num ) ) output.append( " " ) output.pop( ) print( "".join( output ) ) n = int( input( ) ) nums = [ int( val ) for val in input( ).split( " " ) ] trace( nums ) for i in range( 1, len( nums ) ): key = nums[i] j = i - 1 while 0 <= j and key ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,563
s581921668
p02255
u604774382
1432447404
Python
Python
py
Accepted
20
4224
305
n = int( raw_input( ) ) nums = [ int( val ) for val in raw_input( ).split( " " ) ] print( " ".join( map( str, nums ) ) ) for i in range( 1, len( nums ) ): key = nums[i] j = i - 1 while 0 <= j and key < nums[j]: nums[ j+1 ] = nums[j] j -= 1 nums[ j+1 ] = key print( " ".join( map( str, nums ) ) )
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,564
s496923752
p02255
u604774382
1432447499
Python
Python3
py
Accepted
40
6724
297
n = int( input( ) ) nums = [ int( val ) for val in input( ).split( " " ) ] print( " ".join( map( str, nums ) ) ) for i in range( 1, len( nums ) ): key = nums[i] j = i - 1 while 0 <= j and key < nums[j]: nums[ j+1 ] = nums[j] j -= 1 nums[ j+1 ] = key print( " ".join( map( str, nums ) ) )
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,565
s719493724
p02255
u442472098
1433409658
Python
Python3
py
Accepted
40
6724
291
#!/usr/bin/env python3 N = int(input()) A = list(map(int, input().split())) for i in range(1, N): print(' '.join((str(x) for x in A))) v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print(' '.join((str(x) for x in A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,566
s465851394
p02255
u571345655
1434613703
Python
Python
py
Accepted
20
4224
381
# coding=utf-8 def insertionSort(A, N): print ' '.join(map(str, A)) for i in range(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j + 1] = A[j] j -= 1 A[j + 1] = v print ' '.join(map(str, A)) return A n = int(raw_input().rstrip()) a...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,567
s745342437
p02255
u757519851
1435923334
Python
Python3
py
Accepted
40
6752
329
#!/usr/bin/env python def InsertSort(N,A): for i in range(1,N): v=A[i] j=i-1 while j>=0 and A[j]>v: A[j+1]=A[j] j-=1 A[j+1]=v print(*A) if __name__ == "__main__": N=int(input()) arr=list(map(int,input().split())) print(*arr) InsertSo...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,568
s319026649
p02255
u777299405
1436072801
Python
Python3
py
Accepted
40
6756
217
n = int(input()) a = list(map(int, input().split())) for i in range(1, len(a)): 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
30,569
s218802609
p02255
u609407244
1436239870
Python
Python3
py
Accepted
30
6724
260
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 else: print(' '.join(map(str, A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,570
s748603026
p02255
u879226672
1436978158
Python
Python
py
Accepted
20
4220
242
N = int(raw_input()) A = map(int,raw_input().split()) print ' '.join(map(str,A)) for i in xrange(1,N): v = A[i] j = i - 1 while j >=0 and A[j] > v: A[j+1] = A[j] j -= 1 A[j+1] = v print ' '.join(map(str,A))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,571
s448512060
p02255
u802705119
1437455409
Python
Python3
py
Accepted
30
6724
363
def insertSort(a, n): for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(' '.join(map(str, a))) if __name__ == '__main__': n = int(input()) a = [int(i) for i in input().split()] print(...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,572
s174723263
p02255
u802705119
1437455499
Python
Python3
py
Accepted
30
6724
363
def insertSort(a, n): for i in range(1, n): v = a[i] j = i - 1 while j >= 0 and a[j] > v: a[j+1] = a[j] j -= 1 a[j+1] = v print(' '.join(map(str, a))) if __name__ == '__main__': n = int(input()) a = [int(i) for i in input().split()] print(...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,573
s219035561
p02255
u669284080
1437988031
Python
Python
py
Accepted
20
4220
245
N = int(raw_input()) A = map(int, raw_input().split()) print ' '.join(map(str, A)) for i in xrange(1, N): v = A[i] j = i - 1 while j >= 0 and A[j] > v: A[j+1] = A[j] j-=1 A[j+1] = v print ' '.join(map(str, A))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,574
s799950134
p02255
u754727064
1438089706
Python
Python
py
Accepted
20
4228
409
# -*- coding: utf-8 -*- import sys def main(): num = int(raw_input()) list = map(int, raw_input().split()) sort(num, list) def sort(num, list): output(list) for i in range(1, num): key = list[i] j = i - 1 while j >= 0 and list[j] > key: list[j+1] = list[j] j -= 1 list[j+1] = key output(list) def ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,575
s942213976
p02255
u881590806
1439571233
Python
Python
py
Accepted
20
4224
284
n = int(raw_input()) arr = map(int, raw_input().split(' ')) p = 1 print ' '.join(map(str, arr)) while True: if p >= len(arr): break for j in range(0,p): if arr[p] < arr[j]: arr[p],arr[j] = arr[j],arr[p] p += 1 print ' '.join(map(str, arr))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,576
s721830320
p02255
u949338836
1439961151
Python
Python3
py
Accepted
50
8172
332
#coding:utf-8 #1_1_A def insertion_sort(cards, n): for i in range(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) n = int(input()) cards = list(map(int, input().split())) insertion_so...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,577
s389886484
p02255
u722558010
1440668884
Python
Python3
py
Accepted
20
7712
204
n=int(input()) A=list(map(int,input().split())) for i in range(1,n): print(" ".join(map(str,A))) j=i while A[j]<A[j-1] and j>0: (A[j],A[j-1])=(A[j-1],A[j]) j=j-1 else: print(" ".join(map(str,A)))
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,578
s038518121
p02255
u938745275
1440951878
Python
Python
py
Accepted
30
6432
348
def insertionSort(a, n): print " ".join(map(str, a)) for i in xrange(1, n): v = a[i] j = i - 1 # print "i = " + str(i) + ", j = " + str(j) while j >= 0 and v < a[j]: a[j + 1] = a[j] j -= 1 a[j + 1] = v print " ".join(map(str, a)) n = int(raw_input()) a = map(int, raw_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
30,579
s659327009
p02255
u197445199
1442210232
Python
Python
py
Accepted
10
6440
371
num = int(raw_input()) line = raw_input() item_str = line.strip().split(" ") print " ".join(item_str) A = map(int, item_str) for i in range(1, num): v = A[i] j = i - 1 for j in range(j, -1, -1): if A[j] > v: A[j+1] = A[j] j -= 1 else: break A[j+1] = ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,580
s258065238
p02255
u632424921
1442210376
Python
Python
py
Accepted
40
6464
427
num = raw_input() num_list = raw_input() num_list = num_list.split() print " ".join(num_list) for i in range(1, len(num_list)): num_list = map(int, num_list) temp = num_list[i] j = i - 1 while (j >= 0 and num_list[j] > temp): num_list[j+1] = num_list[j] ...
p02255
<H1>Insertion Sort</H1> <p> Write a program of the Insertion Sort algorithm which sorts a sequence A in ascending order. The algorithm should be based on the following pseudocode: </p> <pre> for i = 1 to A.length-1 key = A[i] /* insert A[i] into the sorted sequence A[0,...,j-1] */ j = i - 1 while j >...
6 5 2 4 6 1 3
5 2 4 6 1 3 2 5 4 6 1 3 2 4 5 6 1 3 2 4 5 6 1 3 1 2 4 5 6 3 1 2 3 4 5 6
30,581