|
+1
Sorry for the necropost, but I feel like I have something to add. For the value $$$n$$$ and $$$q$$$, you can also find the left and right bound inclusive $$$[l, r]$$$ for which $$$\lfloor \frac{n}{i} \rfloor = q$$$ or $$$\lceil \frac{n}{i} \rceil = q$$$ for $$$l \leq i \leq r$$$. For $$$\lfloor \frac{n}{i} \rfloor = q$$$ => $$$l = \lceil \frac{n+1}{q+1} \rceil$$$ and $$$r = \lfloor \frac{n}{q} \rfloor$$$ Proof For $$$\lceil \frac{n}{i} \rceil = q$$$ => $$$l = \lceil \frac{n}{q} \rceil$$$ and $$$r = \lfloor \frac{n-1}{q-1} \rfloor$$$ Proof At first I kinda proved it in my head with my imagination and stuff, but I had a lot of trouble proving it formally. I don't really have much of any proof writing experience outside the one course I did on discrete math years ago. I actually learned a lot of stuff by writing this proof. So, if anyone can prove it better or if there's some problem with my proof plz let me know. $$$\newline$$$ CSES - Sum of Divisor solution |
|
0
Damn how did i miss that. I added precision handling on the if(len <= ab) statement later but completely forgot about the other if statement. Thanks |
|
0
I also suspected something similar but it got the right answer in C++14 on ideone, which was 261798.698746. But C++17 on CF got me 361929.351562. It's insane how much the precision error blew up if that's the case. |
|
0
You are right, linear programming will work in this problem. If i make a struct to store vectors and put the values in the simplex algorithm, it would be sufficient for my case. Thanks a lot. |
|
0
Was able to solve this using persistent segment tree to do range MEX queries online instead of offline. https://leetcode.com/problems/smallest-missing-genetic-value-in-each-subtree/solutions/6126019/online-range-mex-with-persistent-segment-tree C++ code |
|
+8
I just copy pasted the text that they showed after i confirmed my order. That's why i used the quotes. |
|
+17
"If you need a size exchange, update your shipping address, or have any questions, please email metaswag@nadel.com and use the subject heading "Hacker Cup 2024 — Shirt Order Confirmation #xxxxx". Please allow 2-3 business days for a reply to account for time differences as we're based in California, USA." |
|
0
|
|
0
You can check this blog |
|
0
I think there's an error in the editorial for problem F. It says "we may find the largest t <= r" but it should be t < r since if t == r then the segment [t+1, r] would not make sense. I tried a solution with this change in mind and it got AC. 259369531 |
|
0
purple hajmola, worst flavor of the bunch |
|
0
Is the judge for Bài toán ba lô 3 broken or something? According to the translation, the problem statement asks me to print "The first line should print the number of items CJ takes to maximize the total value. The second line should print the indices of the selected items in increasing order." But doing that i get wrong answer and it looks like the judge answer is aparantly one number? Like what is even hapenning? Edit: Got it to work. The Judge interface for the OJ was very weird so it caught me off-guard. The problem is as stated in the question. My code's problem was that I had weight as int in my node struct, while I was calling the constructor using a long long variable. So it caused some bugs. Here's my solution: https://ideone.com/2LxqbY Great blog. |
|
0
One thing to note is that the last loop where the bitset L is getting modified, contains the Longest Common Subsequence between string Y and the substring of X from [0, i] after each iteration. So, you could make an vector array of size n and store the L.count() after every iteration to return it and use it in main. P.S. If you have a better implementation of bigint then you can easily make this algorithm faster. My bitset implementation of bigint, while providing me with clarity, was obviously more slower than the bigint implementation in the original code (Thus resulting in more time taken). |
|
0
I have simplified the code as much as i can and this is what i got It is slower now, getting AC at 106ms, using 9.4mb (way worse than even the basic solution to LCS) but it does a fine job of representing what the code in question is actually doing. Deconstructing the code did give me a greater insight into it but I still don't have a complete idea of how it works. |
|
0
Auto comment: topic has been updated by ClosetNarcissist (previous revision, new revision, compare). |
|
0
The cses test cases are kinda weak tho. Like i was able to hack my own "lcm" solution pretty easily Hmmm, the problem with making l using the bigger coins is that all coin combinations does not converge at the lcm and so values are possible which the "lcm" method cannot account for. Although for some reason i feel like it will work if i take 2*lcm using bigger coins greedily and then do the dp. I can't prove this tho, can be wrong. |