Balance
Time limit2sMemory limit128 MB
Count the orders and pan choices for placing n distinct weights so the left pan is never heavier than the right at any step.
- Level
Medium4 of 10
- Topics
- Brute force, Backtracking, Recursion, Combinatorics
- Solved
- No attempts yet
Problem
We are given a two-pan balance and weights of distinct masses . We must place the weights on the balance one at a time so that at no moment is the left pan heavier than the right pan. At each step, we pick one weight that has not yet been placed and put it on either the left pan or the right pan. We repeat this until all weights have been used. Write a program that computes the number of ways to do this.
Input
The first line contains the integer (). The second line contains integers ().
Output
Output a single integer: the number of ways.