Canadian Computing Competition: 2023 Stage 1, Senior #2
Rebecca is a tour guide and is trying to market the Rocky Mountains for her magazine. She
recently took a beautiful picture consisting of
We will measure the asymmetric value of a crop as the sum of the absolute difference for
every pair of mountains equidistant from the midpoint of the crop. To help understand that
definition, note that the absolute value of a number
Because Rebecca does not know how wide the picture needs to be, for all possible crop lengths, find the asymmetric value of the most symmetric crop (the crop with the minimum asymmetric value).
Input Specification
The first line consists of an integer
The following table shows how the available 15 marks are distributed:
Marks Awarded | Bounds on |
Bounds on |
Additional Constraints |
---|---|---|---|
5 | None | ||
5 | Height of mountains are in non-decreasing order from left to right. | ||
5 | None |
Output Specification
Output on one line
Sample Input 1
7
3 1 4 1 5 9 2
Output for Sample Input 1
0 2 0 5 2 10 10
Explanation of Output for Sample Input 1
We will show why the fifth value from the left is
The height of the mountains in the first crop is
The height of the mountains in the second crop is
The height of the mountains in the last crop is
Hence, the most symmetric crop of length
Sample Input 2
4
1 3 5 6
Output for Sample Input 2
0 1 3 7
Explanation of Output for Sample Input 2
This sample satisfies the second subtask. Note that the only crop of
length
Comments
is the second sample case wrong? shouldnt the answer be 0 2 3 7 not 0 1 3 7? because the crops of length 2 that include 3 are [1,3] and [3,5], both of which have a symmetry of 2. so the answer should be 2 right?
It is asking for the minimum asymmetric crop.
My solution in Python passes all subtasks in CCC grader but not on DMOJ :/
If you're getting TLE, try using PyPy3 (faster but takes more memory).
(Python3 isn't fast enough to get AC)
Oh nice it works 👍
This comment is hidden due to too much negative feedback. Show it anyway.
is this doable with python?
Value's get too large for the programs to compute,I was able to write some python, it got AE, but it got a TLE. I asked ChatGPT to convert it to varius languages, it TLE'd except C# where it Gave points but still gave a TLE. So your program has to be very efficient, and use a language that is fast.
seems like no one ACed with Python 3, maybe you should try submitting with pypy 3
https://dmoj.ca/problem/ccc23s2/submissions/?status=AC&language=PYPY3
Nvm s
legend
i literally spent 1 hour to figure out ways to make it as fast as possible and work in python but looks like its impossible
wow thanks dude
RIP CCC score; still have no idea how to solve subtask 3
interval dp
Hint
thanks
Thank you for your hint, your hint is so inspiring that I solved the problem immediately and spontaneously developed an understanding of the c++ language. Thank you.
??? Is that actually a hint?
yeah :D
Did you solve all problems on CCC?
Edit: I just realized you r the author