ผลต่างระหว่างรุ่นของ "Algo lab/running times"

จาก Theory Wiki
ไปยังการนำทาง ไปยังการค้นหา
แถว 3: แถว 3:
 
== Task 1: Closest pairs ==
 
== Task 1: Closest pairs ==
  
{{กล่องสี|#e0e0e0|
+
{{กล่องสี|#e7e7e7|
 
'''Task statement'''
 
'''Task statement'''
  
แถว 17: แถว 17:
 
* One line: the minimum difference between pairs of these integers.
 
* One line: the minimum difference between pairs of these integers.
  
 +
'''Example'''
 +
 +
Input:
 +
<pre>
 +
5
 +
1
 +
50
 +
4
 +
13
 +
25
 +
</pre>
 +
 +
Output:
 +
<pre>
 +
3
 +
</pre>
 
}}
 
}}
  
 
== Task 2: Sorting ==
 
== Task 2: Sorting ==
 +
 +
{{กล่องสี|#e7e7e7|
 +
'''Task statement'''
 +
 +
You are given a list of '''n''' integers.  You want to sort them in an increasing order.
 +
 +
'''Input'''
 +
 +
* First line: integer '''n'''
 +
* Next '''n''' lines: each line contains one integer (ranging from 1 to 1,000,000,000)
 +
 +
'''Output'''
 +
 +
* '''n''' lines: the sorted list of integers
 +
 +
'''Example'''
 +
 +
Input:
 +
<pre>
 +
5
 +
1
 +
50
 +
4
 +
13
 +
25
 +
</pre>
 +
 +
Output:
 +
<pre>
 +
1
 +
4
 +
13
 +
25
 +
50
 +
</pre>
 +
}}
  
 
== Test data ==
 
== Test data ==

รุ่นแก้ไขเมื่อ 00:47, 3 กันยายน 2561

This is part of ske algo lab

Task 1: Closest pairs

Task statement

You are given a list of n integers. You want to find the minimum difference between pairs of these integers.

Input

  • First line: integer n
  • Next n lines: each line contains one integer (ranging from 1 to 1,000,000,000)

Output

  • One line: the minimum difference between pairs of these integers.

Example

Input:

5
1
50
4
13
25

Output:

3

Task 2: Sorting

Task statement

You are given a list of n integers. You want to sort them in an increasing order.

Input

  • First line: integer n
  • Next n lines: each line contains one integer (ranging from 1 to 1,000,000,000)

Output

  • n lines: the sorted list of integers

Example

Input:

5
1
50
4
13
25

Output:

1
4
13
25
50

Test data