Skip to main content

3 posts tagged with "Binary Search"

View All Tags

Question description

There are NN classes in the ABC competitive programming school, and class number ii (1iN1 \leq i \leq N) targets students with a rating of AiA_i.

Now, QQ students are about to join this school. The rating of student number jj (1jQ1 \leq j \leq Q) is BjB_j. Each student will be dissatisfied if they go to a class that does not match their level. The dissatisfaction for each student is defined as follows:

The absolute difference between the target rating aa and their own rating bb, that is, ab|a - b|.

For j=1,2,3,,Qj = 1, 2, 3, \dots, Q, find the minimum dissatisfaction that can be considered for student number jj. It is allowed to have classes with no students or classes with multiple students.


CloverAlgorithmAtcoderBinary Search2 min read

Question description

Output all correct bracket sequences of length NN in lexicographic order.

A correct bracket sequence is defined as follows:

  • () is a correct bracket sequence.
  • When SS is a correct bracket sequence, the string ( + SS + ) is a correct bracket sequence.
  • When SS and TT are correct bracket sequences, the string SS + TT is a correct bracket sequence.
  • All other strings are not correct bracket sequences.

CloverAlgorithmAtcoderBinary Search2 min read

Problem description

There is a Yokan of length LL [cm]. There are NN cutting points, and the ii-th cutting point from the left is at position AiA_i [cm] from the left.

You want to choose KK of the NN cutting points and divide the Yokan into K+1K+1 pieces. Then, the following value is used as the score:

  • The length of the shortest piece among the K+1K+1 pieces

Find the score that can be obtained when dividing the Yokan to maximize the score.


CloverAlgorithmAtcoderBinary Search2 min read