D. Riana and Distribution of Pie

Codeforces
IDCF10255D
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Riana baked a round pie in preparation for her birthday party. After baking the pie, she thought that it would be boring to simply give the pie evenly across everyone attending her party. After some thought, she came up with the idea of using the pie in a game for the party goers. In her game, each person attending the party will each take only one turn. One full turn goes like this: For example, if four people Mathil, Quin, Octavian, and Velyna attend the party: But wait! this is wrong! Riana's household has a strict 'no leftovers' policy, so she wants 100% of the pie to get eaten! Riana is also an advocate of equality, so she wants to distribute the pie slices such that the difference between the biggest slice and the smallest slice is minimized. However, Riana is also secretly lazy, so she enlisted the help of her friend, you! Help her figure out the optimal percentage each person should take. The input will contain one line containing a single integer $N$, the number of people going to the party. The value $N$ is guaranteed to be between *$1$* and *$10^3$*. Output contains $N$ lines. The $i$th line of the output must contain the percentage of the pie which the $i$th person to take slices should take. (The first person's percentage should be on the first line, the second should be on the second line, the third should be on the third line, etc.) Answers will be accepted if they are within $10^(-4)$ away from the correct answer. In the sample test case, since the first person is the only person in the party (quite sad), he takes the whole cake. This satisfies the two conditions that Riana wanted to satisfy: ## Input The input will contain one line containing a single integer $N$, the number of people going to the party.The value $N$ is guaranteed to be between *$1$* and *$10^3$*. ## Output Output contains $N$ lines.The $i$th line of the output must contain the percentage of the pie which the $i$th person to take slices should take. (The first person's percentage should be on the first line, the second should be on the second line, the third should be on the third line, etc.)Answers will be accepted if they are within $10^(-4)$ away from the correct answer. [samples] ## Note In the sample test case, since the first person is the only person in the party (quite sad), he takes the whole cake.This satisfies the two conditions that Riana wanted to satisfy: 100% of the cake is eaten. The difference between the Maximum and the Minimum is minimized. (The difference is 0.)
**Definitions** Let $ n, m, q \in \mathbb{Z}^+ $ denote the number of chunks, servers, and queries, respectively. Let $ P = (p_1, p_2, \dots, p_n) \in \{1, \dots, m\}^n $ be the initial assignment vector, where $ p_i $ is the server hosting chunk $ i $. Let $ Q = \{(a_i, b_i, l_i, r_i) \mid i \in \{1, \dots, q\}\} $ be the sequence of queries, where each query requests to move chunks $ l_i $ to $ r_i $ from server $ a_i $ to server $ b_i $. **Constraints** 1. $ 1 \leq n, q \leq 100{,}000 $ 2. $ 2 \leq m \leq 100{,}000 $ 3. $ 1 \leq p_i \leq m $ for all $ i \in \{1, \dots, n\} $ 4. For each query $ i $: - $ 1 \leq a_i, b_i \leq m $, $ a_i \neq b_i $ - $ 1 \leq l_i \leq r_i \leq n $ **Objective** For each query $ i \in \{1, \dots, q\} $: - If $ \forall j \in \{l_i, \dots, r_i\} $, $ p_j = a_i $, then execute the move: set $ p_j \leftarrow b_i $ for all $ j \in \{l_i, \dots, r_i\} $, and output $ 1 $. - Otherwise, output $ 0 $ (no change to $ P $). Output a sequence of $ q $ values $ o_i \in \{0, 1\} $, where $ o_i = 1 $ iff query $ i $ is executed.
API Response (JSON)
{
  "problem": {
    "name": "D. Riana and Distribution of Pie",
    "description": {
      "content": "Riana baked a round pie in preparation for her birthday party. After baking the pie, she thought that it would be boring to simply give the pie evenly across everyone attending her party. After some t",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10255D"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Riana baked a round pie in preparation for her birthday party. After baking the pie, she thought that it would be boring to simply give the pie evenly across everyone attending her party. After some t...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, m, q \\in \\mathbb{Z}^+ $ denote the number of chunks, servers, and queries, respectively.  \nLet $ P = (p_1, p_2, \\dots, p_n) \\in \\{1, \\dots, m\\}^n $ be the initial assignment...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments