139. Dynamic Sorting

Codeforces
IDCF10269139
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Your computer outputs $n$ integers randomly. You think it might be a secret code, so you decide to make a list of the numbers, but maintain the list in sorted order as you add each number. For example, if the computer output was $3$ $4$ $2$ $8$ $7$, you would first add $3$ to the list, making the list _[3]_. Then, you would add $4$ to the list, making the list _[3, 4]_. Then, you add $2$, putting it first in the list to maintain the list's sorted order. The list becomes _[2, 3, 4]_ The process proceeds until the list is _[2, 3, 4, 7, 8]_ after the final step. The first line of input contains a positive integer $n$: the amount of numbers your computer has printed out. The next $n$ lines contain $n$ integers: the numbers that your computer printed out. Output $n$ lines. On the $k$th line, output $k$ integers: the sorted list after adding the $k$th number from the computer's output to the list. ## Input The first line of input contains a positive integer $n$: the amount of numbers your computer has printed out.The next $n$ lines contain $n$ integers: the numbers that your computer printed out. ## Output Output $n$ lines. On the $k$th line, output $k$ integers: the sorted list after adding the $k$th number from the computer's output to the list. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of integers. Let $ A = (a_1, a_2, \dots, a_n) $ be the sequence of integers from input. Let $ L_k $ be the sorted list after inserting the first $ k $ elements of $ A $, for $ k \in \{1, \dots, n\} $. **Constraints** 1. $ 1 \leq n \leq \text{large enough for practical sorting} $ 2. Each $ a_i \in \mathbb{Z} $ **Objective** For each $ k \in \{1, \dots, n\} $, output the sorted list $ L_k = \text{sort}(a_1, a_2, \dots, a_k) $ as a sequence of $ k $ integers in non-decreasing order.
API Response (JSON)
{
  "problem": {
    "name": "139. Dynamic Sorting",
    "description": {
      "content": "Your computer outputs $n$ integers randomly. You think it might be a secret code, so you decide to make a list of the numbers, but maintain the list in sorted order as you add each number. For exampl",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269139"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Your computer outputs $n$ integers randomly. You think it might be a secret code, so you decide to make a list of the numbers, but maintain the list in sorted order as you add each number.\n\nFor exampl...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of integers.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be the sequence of integers from input.  \nLet $ L_k $ be the sorted list after inserting th...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments