From 7eb5c968bfd30f45ac45d0103c0ca2e215847ac7 Mon Sep 17 00:00:00 2001 From: freakin23 Date: Tue, 21 Jan 2025 18:05:24 +0530 Subject: [PATCH] update max_n --- solutions/silver/cf-1077D.mdx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/solutions/silver/cf-1077D.mdx b/solutions/silver/cf-1077D.mdx index 816064eb52..7e61790a34 100644 --- a/solutions/silver/cf-1077D.mdx +++ b/solutions/silver/cf-1077D.mdx @@ -24,12 +24,12 @@ Once it is calculated, construct the resulting array by including elements in pr #include #include -const int MAX_N = 200001; +const int MAX_N = 200000; int main() { int n, k; std::cin >> n >> k; - std::vector freq(MAX_N); + std::vector freq(MAX_N + 1); std::vector res; for (int i = 0; i < n; i++) { int x; @@ -39,7 +39,7 @@ int main() { std::function can = [&](int x) { int ele_num = 0; - for (int i = 1; i < MAX_N; i++) { ele_num += freq[i] / x; } + for (int i = 1; i <= MAX_N; i++) { ele_num += freq[i] / x; } return (ele_num >= k); }; @@ -53,7 +53,7 @@ int main() { } } - for (int i = 1; i < MAX_N; i++) { + for (int i = 1; i <= MAX_N; i++) { for (int j = 0; j < freq[i] / lo; j++) { res.push_back(i); } } @@ -65,13 +65,13 @@ int main() { ```py -MAX_N = 200001 -freq = [0] * (MAX_N) +MAX_N = 200000 +freq = [0] * (MAX_N + 1) def can(x: int) -> bool: ele_num = 0 - for i in range(1, MAX_N): + for i in range(1, MAX_N + 1): ele_num += freq[i] // x return ele_num >= k @@ -94,7 +94,7 @@ while lo < hi: else: hi = mid - 1 -for i in range(1, MAX_N): +for i in range(1, MAX_N + 1): for j in range(0, freq[i] // lo): res.append(i)