# | User | Rating |
---|---|---|
1 | jiangly | 3846 |
2 | tourist | 3799 |
3 | orzdevinwang | 3706 |
4 | jqdai0815 | 3682 |
5 | ksun48 | 3590 |
6 | Ormlis | 3533 |
7 | Benq | 3468 |
8 | Radewoosh | 3463 |
9 | ecnerwala | 3451 |
9 | Um_nik | 3451 |
# | User | Contrib. |
---|---|---|
1 | cry | 165 |
2 | -is-this-fft- | 161 |
3 | Qingyu | 160 |
4 | atcoder_official | 157 |
5 | Dominater069 | 156 |
6 | adamant | 154 |
7 | Um_nik | 151 |
7 | djm03178 | 151 |
9 | luogu_official | 149 |
10 | awoo | 147 |
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 |
---|