Repovive
  • Dashboard
  • Ranking
  • Submissions
  • Discussion
  1. Contests
  2. Premier Round 9
  3. 27C

My submissions

/
/
/
/

Announcements

My submissions

/
/
/
/

Announcements

Solve
Author

Think of a dance by its level

Call a person's jjj-th dance a dance of level jjj.

Pairing a man's level ppp with a woman's level qqq is legal exactly when p≥qp\ge qp≥q. Before that turn, their counts are p−1p-1p−1 and q−1q-1q−1.

Now imagine fixing final counts xix_ixi​ for the men and yiy_iyi​ for the women. Both totals must equal the number of turns TTT.

Each man contributes levels 1,2,…,xi1,2,\ldots,x_i1,2,…,xi​; each woman contributes levels 1,2,…,yi1,2,\ldots,y_i1,2,…,yi​.

The task becomes matching these two collections so that every male level is at least the female level matched to it. This removes the need to reason about every possible schedule.