Level Design
Time limit1sMemory limit1024 MB
Permute the values 1 to N over rooms 1 to N to minimize the largest non-adjacent subset sum, then print the permutation and that minimum.
- Level
Medium7 of 10
- Topics
- Greedy, Dynamic programming, Array
- Solved
- No attempts yet
Problem
The time limit is 1000 ms and the memory limit is 1024 MB.
There are levels numbered from to . The levels are arranged in the order , and the player starts at level and advances in order until level . The player cannot return to a level already visited or skip a level.
Except for room and room , each of the rooms holds one item that adds points. If the player takes the item in room , the player gains points. In each level, the player decides whether to carry the item, but the player cannot carry items in two consecutive levels.
Byungyoon wants to rearrange the items so that the maximum score the player can earn is as small as possible. The rearrangement must satisfy the following conditions.
- Rooms each contain exactly one item.
- Let be the score of the item in room after the rearrangement. must be a permutation in which each integer from to appears exactly once.
Find one arrangement of items that satisfies these conditions, and find the maximum score the player can earn with that arrangement.
Input
The first line contains an integer . ()
Output
The first line prints separated by spaces.
The second line prints the maximum score the player can earn with that arrangement.
If several arrangements satisfy the conditions, any of them is accepted.