In the problem description of Codeforces Round 862 (Div. 2) F1. Survival of the Weakest (easy version), it describes the fact that the answer can be quite large and needs to be outputted modulo 10^9 + 7. While trying to get this answer, I ran into the problem that the answer itself was far too big to even fit in a long long, as codeforces threw an integer overflow error on test case 5. How can I keep the numbers small? Can this problem be done with long long, and is there just a problem with my code?
My solution is a faster version of brute force. Normally, one would think of brute forcing all pairs, but would cause the problem to run in N^3. My idea comes from the fact that in a vector sorted in non decreasing order, for any given index,f, as you move the index you pair with it ,s, forward, the sum of the two will naturally get larger. So I added to a priority queue every index and the one index after each one(excluding the very last one index). Then I extracted the two indices that had the smallest sum and added it to a new vector, and then moved the second indice forward, which was repeated the size of the vector-1 times.
Code is below in the failed submission.








Actually I don't need the help anymore. I found this: https://codeforces.me/blog/entry/72527[Your text to link here...](https://codeforces.me/blog/entry/72527)
Do problems that are at the same level as you
Problems that are newbie level are problems for people that just learned programming.
bro the problem is 2600 rated
Take a look at my rating when I challenged myself with these problems
https://codeforces.me/contest/712/problem/D
https://codeforces.me/contest/716/problem/D
https://codeforces.me/contest/722/problem/E
https://codeforces.me/contest/11/problem/D
All of those I solved with the help of the editorial. Contrary to what you seem think, people get better by challenging themselves. Staying in your comfort zone will get you nowhere.
I don't stay in my comfort zone, I meant problems around your level.
The problems you solved are easier than the rating says, due to them being very old. I don't think those problems were like ever that hard for you, your rating raising so fast.
I spent hours and hours after reading the editorial and trying to implement these solutions. They weren't easy at all.
You have it backwards about the rating as well. Newer similar problems will have lower rating BECAUSE they appeared before and the word has spread about their ideas. It's not because the problem is easy. Even then I remember a recent problem that was similar to that 11D and people failed horribly at it. https://codeforces.me/problemset/problem/1804/E this is the problem if you're curious about it, it has HIGHER rating than the 11D.
I'm talking from my experience, old problems are way easier.
With that mentality LmuEmuLiberty is getting Expert before you get pupil. Do the hardest problems you can.
I'm talking about around his level, that problem is nowhere near his level
If you only apply the % MOD at the end of the problem you might get overflows. You should apply it after every product or sum. It seems like you already learned this.
In your latest submissions you are overdoing it though, you don't need (a%MOD+b%MOD)%MOD, just (a+b)%MOD is enough.
Additionally, a trick for making modulo slightly faster is doing something like this
This only works on sums though (not products), and only if you've already taken the modulo of a and b.
Not sure why you're still getting WA though, maybe your idea is just wrong. I haven't read the problem.