#P10849. [EGOI 2024] Bike Parking / 车位分配
[EGOI 2024] Bike Parking / 车位分配
Background
Day 2 Problem B.
This statement is translated from EGOI2024 bikeparking. The translation comes from ChatGPT and has been manually proofread. If there are mistakes, please contact rui_er.
Problem Description
Sanne recently came up with a profitable business idea: renting out premium bike parking spots at Eindhoven train station. To maximize her profit, she divides the bike parking spots into different levels, numbered from to . Level is the premium level and is very close to the platforms. Higher-numbered levels have worse parking spots. The number of parking spots at level is .
Users are assigned their parking spots via an app. Each user has a subscription level and expects to get a parking spot at the corresponding level. However, the terms of service do not guarantee that users will get a spot at their corresponding level.
If a user with subscription level is assigned to a parking spot at level , then one of the following three cases happens:
- If , the user is happy and will like the app.
- If , the user is satisfied and will not react.
- If , the user is angry and will dislike the app.
Today, Sanne's app has users, where is the number of users with subscription level . She needs your help to assign users to parking spots. Each user must get a parking spot. A parking spot cannot be assigned to multiple users, but some parking spots may be left unassigned. Also, the total number of users does not exceed the total number of available parking spots.
Sanne wants to maximize her app rating. Let be the number of likes and be the number of dislikes. Your task is to maximize by assigning users to parking spots in the best possible way.
Input Format
The first line contains an integer , the number of levels or subscription levels.
The second line contains integers , the number of parking spots at each level.
The third line contains integers , the number of users at each subscription level.
Output Format
Output one integer, the maximum possible value of that can be achieved by an optimal assignment of users to parking spots.
2
3 3
1 3
2
3
1 1 1
1 1 1
1
6
1 0 1 1 0 1
1 1 0 0 1 0
1
4
2 1 1 8
0 4 4 0
-1
1
1000000000
1000000000
0
Hint
Sample Explanation
In the first sample, you can assign the users with subscription level to level parking spots, assign two users with subscription level to level parking spots (getting 2 likes), and assign the remaining users with subscription level to level parking spots. This results in a rating of .
In the second sample, you can assign the level user to a level parking spot, assign the level user to a level parking spot, and assign the level user to a level parking spot. This results in 2 likes and 1 dislike, for a rating of .
In the third sample, you can assign the level user to a level parking spot, assign the level user to a level parking spot, and assign the level user to a level parking spot. This again results in 2 likes and 1 dislike, for a rating of .
The fourth sample is shown in the figure below. You can assign level users to level parking spots, resulting in 2 likes and 2 dislikes. Next, assign level users to level parking spots, resulting in 1 like and 2 dislikes. This totals 3 likes and 4 dislikes, for a rating of .

In the fifth sample, you can assign everyone to a parking spot matching their own subscription level, so the rating is .
Constraints
For all testdata, , , $y_0+y_1+\cdots+y_{N-1}\le x_0+x_1+\cdots+x_{N-1}\le 10^9$.
- Subtask 1 ( points): , , .
- Subtask 2 ( points): For any , .
- Subtask 3 ( points): .
- Subtask 4 ( points): .
- Subtask 5 ( points): No additional constraints.
Note: Some test points in EGOI were placed into multiple subtasks. To save judging resources and reduce the workload of organizing the data, these test points were placed in the subtask with the smallest index among all subtasks that contain them. This may cause a solution to get a higher score than expected, but still fail to pass the problem.
Translated by ChatGPT 5