Algo lab/running times

จาก Theory Wiki
รุ่นแก้ไขเมื่อ 00:56, 3 กันยายน 2561 โดย Jittat (คุย | มีส่วนร่วม) (→‎Test data)
(ต่าง) ←รุ่นแก้ไขก่อนหน้า | รุ่นแก้ไขล่าสุด (ต่าง) | รุ่นแก้ไขถัดไป→ (ต่าง)
ไปยังการนำทาง ไปยังการค้นหา
This is part of ske algo lab

Lab descriptions

  • Work on this lab sheet.
  • Write quadratic-time solutions to the following two problems.
  • Download fast solutions.
  • Measure their running times using provided test data and compare them.

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 (n is at most 100,000)
  • 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

Your job

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 (n is at most 100,000)
  • 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

Your job

Test data