| # | User | Rating |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | turmax | 3559 |
| 6 | tourist | 3541 |
| 7 | strapple | 3515 |
| 8 | ksun48 | 3461 |
| 9 | dXqwq | 3436 |
| 10 | Otomachi_Una | 3413 |
| # | User | Contrib. |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 147 |
| 4 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 142 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
A2SV G6 — Round #6 (Editorial)
Here is the contest link.
Simply put, the problem is asking us to represent $$$S$$$, as a summation of numbers from the set $$${1, 2, 3, … ,n }$$$.
Obviously there are many ways to do that, for example one might use $$$1$$$ $$$S$$$ times, but in this problem we are asked to use the minimum number of elements and output how many we used.
Since we have all the numbers from $$$1$$$ to $$$n$$$ and we can use each element repeatedly, we can afford to be greedy and always use the largest value less or equal to $$$S$$$, until we get the sum of the selected elements equal to $$$S$$$. This ensures that we use the fewest possible numbers.
This process can easily be represented by a ceil division of $$$S$$$ by $$$n$$$.
because $$$⌈S/n⌉$$$ tells us how many times we would need to add the largest possible number (which is $$$n$$$) to reach or exceed $$$S$$$.
Time complexity: $$$O(1)$$$. Space complexity: $$$O(1)$$$
n,S = map(int, input().split())
print((S + n - 1) // n)
| Rev. | Lang. | By | When | Δ | Comment | |
|---|---|---|---|---|---|---|
| en15 |
|
A2SV_Group6 | 2025-03-11 12:11:43 | 9 | Tiny change: '\nFor the last popped i' -> '\nFor the current popped i' | |
| en14 |
|
A2SV_Group6 | 2025-03-11 11:26:30 | 2 | (published) | |
| en13 |
|
A2SV_Group6 | 2025-03-10 15:23:43 | 3202 | ||
| en12 |
|
A2SV_Group6 | 2025-03-10 15:04:17 | 173 | ||
| en11 |
|
A2SV_Group6 | 2025-03-10 15:03:30 | 3608 | ||
| en10 |
|
A2SV_Group6 | 2025-03-10 14:54:56 | 883 | ||
| en9 |
|
A2SV_Group6 | 2025-03-10 14:44:21 | 5 | ||
| en8 |
|
A2SV_Group6 | 2025-03-10 14:07:50 | 2 | Tiny change: 'ary="Hint 3">\nWhen a' -> 'ary="Hint 2">\nWhen a' | |
| en7 |
|
A2SV_Group6 | 2025-03-10 14:07:15 | 7 | ||
| en6 |
|
A2SV_Group6 | 2025-03-10 14:05:24 | 78 | ||
| en5 |
|
A2SV_Group6 | 2025-03-10 13:59:19 | 17 | ||
| en4 |
|
A2SV_Group6 | 2025-03-10 13:54:41 | 1893 | ||
| en3 |
|
A2SV_Group6 | 2025-03-10 13:50:46 | 1151 | ||
| en2 |
|
A2SV_Group6 | 2025-03-10 13:42:10 | 432 | ||
| en1 |
|
A2SV_Group6 | 2025-03-10 13:32:05 | 1251 | Initial Revision (saved to drafts) |
| Name |
|---|


