
Hello Codeforces!
The series of Educational Rounds continues thanks to the support of the Neapolis University Pafos. They offer a BSc in Computer Science and AI with JetBrains Scholarships. Gain cutting-edge skills in AI and machine learning, preparing you for high-demand tech careers. Limited scholarships available — don't miss your chance to study in Europe for free!
On Sep/15/2025 17:35 (Moscow time) Educational Codeforces Round 182 (Rated for Div. 2) will start.
This round will be rated for the participants with rating lower than 2100. It will be held on extended ICPC rules. The penalty for each incorrect submission until the submission with a full solution is 10 minutes. After the end of the contest, you will have 12 hours to hack any solution you want. You will have access to copy any solution and test it locally.
You will be given 6 or 7 problems and 2 hours to solve them.
The problems were invented and prepared by Adilbek adedalic Dalabaev, Ivan BledDest Androsov, Maksim Neon Mescheryakov, Roman Roms Glazov and me. Also, huge thanks to Mike MikeMirzayanov Mirzayanov for great systems Polygon and Codeforces.
Good luck to all the participants!
Our friends at Neapolis University Pafos also have a message for you:
🚀 Free Math, AI, and Coding Clubs
Neapolis University Pafos, in collaboration with JetBrains, invites school students (ages 13–19) to join the Math, AI, and Coding Clubs — weekly programmes designed to build your problem-solving skills through curated challenges and live sessions.
Don't miss the chance to sharpen your skills (and enjoy some fun mashup contests, curated by pashka).
🔹 Math Club
Build a strong mathematical foundation to improve your programming skills. You’ll receive 10–15 progressively challenging problems each week, along with a 90-minute live session every Saturday. Two difficulty levels are available, so you can choose the path that suits you best.
💡 Top performers will be awarded 5 bonus points on the entrance test for the BSc in Computer Science and Artificial Intelligence at Neapolis University Pafos — a fully funded programme supported by JetBrains Foundation Scholarships.
👉Join the Math Club
🔹 AI Club
Explore the world of Artificial Intelligence — from beginner concepts to olympiad-level topics (e.g. IOAI). Attend live sessions every Wednesday and complete weekly homework assignments to keep progressing.
👉Join the AI Club
🔹 Coding Club
Ideal for students with some experience in competitive programming who want to take their skills further. Each week features a mashup of problems from past Codeforces contests, curated by Pavel Mavrin (2004 ICPC World Champion, 2002 IOI Silver Medalist, and JetBrains Academy instructor).
👉Join the Coding Club
🎯 Show off your skills:
Take part in the third edition of the JetBrains Youth Coding Challenge — open to school students aged 13–19. Top participants will be invited to the fourth Algorithm and Code Training Camp (ACTS) 2026.1 in Romania or to ACTS Online in January 2026.
UPD: Editorial is out








expert now?
I trust u.
i am a beginner therefore i dont know much abt it. i have i question that why didnt i got any after yesterday's div 4 contest ?? Is there any delay in results??
u registered unrated for that contest.
You should click the rated button if there is when registering
That's only for div.4. For other divs, your rating decides whether you are rated or not.
so if am less than 1000 would i be unrated for div 2??
Rated. Read the blog top there. It said "will be rated for the participants with rating lower than 2100".
Math, AI, Coding clubs sound like an amazing chance for beginners to grow their skills
Is this a rated contest? Can someone kindly answer?
This round will be rated for the participants with rating lower than 2100
Hi awoo,
Anything you can do to help with the crawling bans for hacking? These crawling bans have three key disadvantages:
On other platforms (such as leetcode), I can freely click through submissions which is valuable for additional test cases and cheat detection. On codeforces it seems like there’s a unique technical constraint that currently results in broad bans on anyone clicking through submissions at a normal pace.
Anything you can do to improve the experience for people who enjoy contributing to hacking rounds would be greatly appreciated.
Thanks,
DarkTemplarDrop
And I've been banned for crawling...
Second ban oof.
What's crawling?
They have some kind of detector that determines whether you are a bot or not, and then you get banned from clicking into submissions for hours at a time. The detector currently is very bad at distinguishing a bot from a human.
I hope I can reach Cyan in this contest
I hope you reach Cyan in this contest
Hope for me too
Hope for both of us
i hope too
will i return to expert? we are waiting :)
I hope you reach it :)
no unrated participation?
why unrated? trust yourself
Sometimes there are occupancies during the contest timings, its better to participate unrated than to use an alt account.
Maybe you can wait for another day and do virtual participant.
click to see all of the contest registrants, and there is a button for changing to unrated
It would be great to have the unrated participation option available for all the contests, always, MikeMirzayanov ❤️
6 or 7 problems?
Not able to participate as unrated ;-;
click to see all of the contest registrants, and there is a button for changing to unrated
wish to be a pupil
For some reason I have a button to register unrated, and it does not show me that I am out of competition, and I'm definitely over 2100 rating.
As dumb a question as this might be, but are all the Educational rounds hosted by Neapolis University Pafos?
If yes, then what are they for exactly? Honestly, I join for rating.
Is it normal for so many submissions for a problem like D. It doesn't felt that easy.
agree with you. To me, E1 is much easier than D.
agree
agree
How did so many solve E1????
Yet another time I feel E<D. Got stuck on D for one hour and do not have time to implement E2 :(
Can u give me some hints for E1? I don't know I made some observations but feel stuck now.
L is strictly increasing, and R is strictly decreasing. Therefore, L and R have only one item in common, which is the end of L and the beginning of R. So we consider enumerating these positions and calculate the sum.
Consider using dynamic programming to calculate the number of ways each position can be the end of a subsequence. The final answer is obtained by choosing an endpoint for L and a starting point for R, and then multiplying by the number of ways to select arbitrarily from the middle.
Thanks, mate.
what rating range of question should I solve if I am stuck at C always for Div2?
Looks like I found you again mate while scrolling, keep trying man you will make it to green. Also try to solve problems in an organized matter like do usaco they have cf problems and ones from other sites organized in every category. Like for example c was just dp nothing else as simple as that you just have to do some for a long time in the usaco
speedforces
well well well , good D. Don't know how people solved it, stared screen for 1:30 Hour
Just iterate on all $$$x \leq 3e5$$$.
What?
Iterate on $$$x$$$, iterate on $$$i$$$, find all $$$c_i$$$ that satisfies $$$ceil(c_i / x) = i$$$. We can break when $$$ix \geq 2e5$$$, so the total time complexity is $$$O(n\log n)$$$.
care to shed some light
wouldnt it result in TLE ?
The audacity to cheat and simultaneously give advice is laughable.
Yeah right, and I solved E1 and you couldn't solve D too.
you could consider every element in array, and check how many of its multiple exists in arrray. worse case array is [1,2,...,2e5] so 1st element takes N iterations 2nd element takes N/2 iterations so on, its just O(NlogN) now just check which x is optimal.
example: 50 150 450 x = 3 is optimal since 50*3 exists, and 150*3 exists, so you could get 2 items for free just maintain some freq array where fr[i] tells how many if x = i, how many items you get free
Let $$$\max c_i = A$$$. You don't need $$$x \gt A$$$, since $$$x = A$$$ gives the same result (except for the case $$$A = 1$$$).
For a given $$$x$$$, you can get the answer as follows: for each $$$i$$$ from $$$1$$$ to $$$\frac{A}{x}$$$, calculate the number of items getting price $$$i$$$ (these are all items from $$$i \cdot (x-1) + 1$$$ to $$$i \cdot x$$$, and you can get the number of them in $$$O(1)$$$ using prefix sums).
So, for a given $$$x$$$, we can get the answer in $$$O(\frac{A}{x})$$$. This gives us a complexity of $$$O(A + \frac{A}{2} + \frac{A}{3} + \dots + \frac{A}{A}) = O(A \log A)$$$, plus $$$O(n + A)$$$ for building the prefix sums.
wow!
Very cool problem. I think it should be $$$(i - 1) \cdot x + 1$$$.
My impl: https://codeforces.me/contest/2144/submission/338828720
wow!
Can someone tell how did they solve D?
Hi there, this is my solution for D. So you will try all X, if you have X, there 200000/X value that you can potentially keep. Now let say one of these value you can keep as J.If you divide all C[i] by X.All C[i] that has value from (J-1)*X+1 to J*X will become J.And the number of sign you can save is MIN(C[J],Number of sign from (J-1)*X+1 to J*X. Now that we have a solution, how do we know this can run in allowed time constraint. Let's say our complexity is 2e5/1 + 2e5/2 +...+2e5/2e5. This sum shall be equal to 2e5LOG. Hope this help.
Why does Writing code in java gives TLE in D wheras CPP code works
Because Scanner is slow.
Logic for C ?
...can be solved using DP (2dp arrays one for swap and one for no swap)
There is always a solution, so the minimum answer is 2. First, create a valid solution for both arrays, then see if you can swap any position. If you can, just multiply by 2 each time. 338832246
can someone explain whats wrong in my code
dp[0][1] would be 1, no?
is my dp transition is correct
Yes. Your DP transitions are correct.
dp[0][1] = 0; is wrong i guess it should also be initialized to 1
You are doing modular arithmetic wrong first and third additions are wrong while second and forth are correct
yes , i took wrong modulo value
Bruh minGW straight up deleted my files instead of compiling and then said "oh whoopsie I can't find the file :D"
I was able to even recover E once somehow and then it happened again sadge
NOOOOOOOOOOOOOOOOOOO (it's so over I can't even write the compilation command right)
Sad. I think you should look into less tedious ways. Also, you will only be working on one problem at a time so why not just use
g++ E.cppand use thea.outexecutable?I think changing the position of -o will fix the problem: g++ E.cpp -o E
yeah learned that the hard way :')
got MLE on PD...
time: $$$O(n \sqrt {n})$$$
space: $$$O(n \sqrt {n})$$$
I forgot that $$$O(n \sqrt{n})$$$ is too large for space complexity...
D was really good problem. Any hints ?
Consider some final price, p. Now for some i, p = ceil(c[i] / x). Now, it's easy to see that we will get the same price p for not only c[i] costs but for a range of costs. Suppose x = 5, then ceil(50 / 5) = ceil(49 / 5) = ceil(48 / 5) = ceil(47 / 5) = ceil(46 / 5) = 10. So, a good idea is : we can find the range and work on how many times the elements in that range will appear in the original array.
p — 1 < c[i] / x <= p -> c[i] ∈ [(p — 1) * x, p * x]; x ∈ [2, max_cost]
We can simply store the frequency of each cost in a frq array and make another prefix sum array called pref such that pref[j] — pref[i — 1] = Number of occurrences of elements from the range i to j. Then iterate over all x and get the new sum of the array of costs. For each value of x, we'll get a result = sum — y * (n — cnt); where cnt = Number of elements in the range [x * (p — 1) + 1, p * x], p is calculated for the corresponding x. Finally maximize the ans. ans = max(ans, result); Time Complexity = O(max * log(max));
Time Complexity is not $$$O(n^2)$$$ you can optimize by fixing a MAX value till which the old array elements are and now for each $$$x$$$ the range of $$$p$$$ you have to check is such that $$$(p-1)x + 1 \leq MAX$$$ so $$$p \approx \frac{MAX}{x}$$$.So total time is
oh my bad. Lemme edit that.
Hey I got same idea to find the frequency quickly but unable to get the Idea of frequency array pref can you give a little bit more detail
Umm it's quite straightforward. U just make a frequency array, vectorfrq(max_cost + 5, 0) and store the frequency of the elements of the original array there. Then to calculate the frequency of the elements in a range efficiently, use another array as the prefix sum array, vector pref(mx + 5, 0) where pref[i] = pref[i — 1] + frq[i], for all i ∈ [1, mx]. Now, we can calculate the frequency of a range of elements in O(1). ∑frq(l, r) = pref[r] — pref[l — 1];
couldn't even solve A. Problem A was definitely higher than 800, or maybe I'm too dumb.
you are not stupid, you just make it too hard sometimes
you just have to look at the problem from a different angle
also A is 1000 in my opinion!
its just bruteforcing l and r why 1000?
Screencast with commentary
My solution for C. Idk what is wrong in this. Plz help
Why is this wrong someone explain plz
try to solve the problem in O(n)
very simple
for each ai , bi or there is either 1 way or there are 2 ways (you can swap)
try greedy
What does $$$2^{dp[j]}$$$ mean here? It seems too big.
We must ensure that after all decisions, both arrays are sorted.
We need a DP-based solution since trying all 2^n subsets explicitly is too slow.
dp[i][0] = number of valid ways to reach index i where we do NOT swap a[i], b[i]
dp[i][1] = number of valid ways to reach index i where we DO swap a[i], b[i]
dp[1][0] = dp[1][1] = 1; At the first position, both swap and no-swap are allowed.
Transition for each i = 2 to n:
Each transition checks if the current pair (either swapped or not) can maintain sorted order from the previous state (either swapped or not).
After processing all indices, the answer is dp[n][0] + dp[n][1].
Submission : 338809665
Stuck in D for an whole hour getting both MLE and TLE because I thought the intended solution is $$$O(N\sqrt{N})$$$. sad.
me too...
me too..
Wasted whole hour proving $$$O(N\sqrt{N})$$$ solution, but just realized that effort was in vain.
could you explain how we do in O(N * sqrt(N))?
you can prove that x is not greater than sqrt(maxValue), with maxValue is max(a1, a2, ..., an)
So you can for loop for each i from 1 to N, and then for loop x
But this is not correct solution, I wasted more than hour for this :(. Poor me
me too... I thought that it's solved by dividing $$$x$$$ by $$$\frac{A_i}{x}$$$
I got it completely wrong...
E1<<<D
I felt like time limit was too tight for D :/
My nlogn solution in cpp TLEed
Also, i didnt get the point of having 10 test cases per test without any limit on the sum of n. That can allow 2e6 input elements with 2 sec limit
$$$t$$$ was 10 because we need to calculate range frequency sums and $$$c_i$$$ ranges upto $$$2e5$$$
Use fast I/O.
ios_base::sync_with_stdio(false); cin.tie(NULL);add this at the beginning of the main function and it should pass.The current time limit for Python on problem E1 seems too strict. My solution, which is clearly O(n^2), times out on test 20 even though this complexity should be acceptable for the given constraints. Could you please consider raising the Python time limit and rejudging all Python submissions for this task? Here is my code for reference (it’s straightforwardly O(n^2), submitted on PyPy 3.10) : 338820099
I think this is slower than $$$O(n^2)$$$, it looks to be $$$O(n^2 \log n)$$$ because of using
pow.Hi BledDest, do you have admin privileges to remove crawling bans?
No, I don't have them. Probably the only ones who have them are MikeMirzayanov and Vladosiya.
You’re right, the pow calls explains the Python TLE (even though C++ passes)
solving A with brute force with 3 loops ; )
Sat like a fish out of water after seeing D :(
Straightforward for D:
When an old tag cj “covers” a new price ceil(ci / x):
Range of cj for fixed x:
Frequencies and prefix sums over original prices:
How many ci produce the new price cj:
How many tags are reused:
Enumeration:
Complexity:
Submission. Made in 4 hours :-))
I think it was a decent Edu round.
To solve problem C, I used this O(n) approach.
Let dp[i] be the number of good subsets that use elements from positions 1 to i.
If a[i] ≥ a[i-1],
a[i] ≥ b[i-1],
b[i] ≥ b[i-1],
b[i] ≥ a[i-1]
then adding index i+1 is optional. For every existing good subset, we can either keep it as is or include i+1, which doubles the count: dp[i+1] = 2 * dp[i]
Otherwise, adding index i+1 is required to maintain validity, so the count stays the same: dp[i+1] = dp[i]
This is an interesting submission :)
I’d take a look, but currently banned for “crawling”.
I don't understand my D solution. I calculated prefix sums until 2e5, wrong answer on test case 5. But when i changed it to 3e5, it ACed? Why's that happening? shouldn't we check only until max value?
https://codeforces.me/contest/2144/submission/338844703
Your inner for loop looks like
for(ll j=i;j<=200001;j+=i). You deriver = j, l = j - i + 1from it. Ideally, we will only need to check till 2e5, not 2e5 + 1.Now consider the case where
j > 2e5, butj-i+1 <= 2e5. Yourj <= 2e5condition will evaluate to false, but you end up missing the elements in the range[j-i+1, 2e5]. So, what you should do is check forj-i+1 <= 2e5and setl = min(j, 2e5)instead.AC with these changes: https://codeforces.me/contest/2144/submission/338884584
These questions are all very interesting and I really like them.
sadly, don't solve problem D in contest, i realized that I needed to enumerate over the value domain, but in the end, I still didn’t figure it out clearly.
My screencast here
The testcases for C are so weak that my dp code passes only just MODing the final answer.
Code
I have reached home from office nearly one hour after the contest began… yet that didn’t stop me from scoring 3 problems on the very first attempt within 50 minutes, Siuuu...
I think peaple's feedbacks with D is interesting. Seems $$$O(n + \frac{n}{2} + \frac{n}{3} + \dots + \frac{n}{n}) = O(n \log n)$$$ is a well known trick. But after some simple transformations, it did confuse many people, including me :)
What's the difference between educational rounds and normal div2 rounds?
Different scoring style and the problems are more of educational kind(they teach u some concept)
Why is there no score for this contest?
$$$O(n^2)$$$ passes for D https://codeforces.me/contest/2144/submission/338807854
That is not O(n^2). If you see he is terminating the 2nd loop if j*i<=3e5 which reduces the time complexity to O(nlogn).
it’s my code lol. Thats not the part thats n^2. Look at the next part of the code.
You have a big fat if statement before that second loop It ensures that the loop for j 0->n is not run everytime.
Sure, but there’s no reason to believe that that heuristic should prevent it from being O(n^2).
where is rating?
My first rated match. Solved Problem B. In problem A, printed arr[i] and arr[j] instead of I and j. But timer got over. Friends,can you tell if div 2 regular round is tougher than educational round div 2.
Yeah I feel regular div2's are a bit harder than most of the Edu's.
can somebody tell me where i am going wrong ? submission for D
Where is the editorial?
In the recent Educational Codeforces Round 182 (Rated for Div. 2), I noticed that the code of this user kzhi shows signs of code plagiarism (338807618). He obfuscated his code, and I feel like he might have taken the solution from AI. I sincerely hope that the admins MikeMirzayanov and the contest organizers awoo can permanently ban this case.
please upload the editorial
Editorial????
Auto comment: topic has been updated by awoo (previous revision, new revision, compare).