Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
How to solve the Place Students problem shown below?

Question: Place Students

Problem Statement: There are N consecutive seats in the classroom. Each seat is either defective or not

In the classroom, there are X boys and Y girls students present. And you want to place them in such a way that there are no two consecutive (adjacent) seats where two boys or two girls are sitting Your task is to find the maximum number of students you can place Note: You can't place a student where the seat is defective.

Constraints:

1<=T<=10
1 <=N<= 10^5
0<=X, Y<=10^5

Input Format:
-> The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows

-> The first line of each test case contains three space-separated integers N, X, and Y.

-> The second line contains a string with length N, consisting of characters *.” and “#”. The dot means that the corresponding place is not defective. The hash (“#”) means that the corresponding place is defective

Output Format:
-> For each test case, print the maximum number of students you can place

Sample Input
7 1 4
.#....#
11 3 10
.#....#.#..
2 1 4

Sample Output
4 8 0

Explanation of Sample:-
Sample case 1: you can put 1 boy and 3 girls in the following way: “GHGBG#”
Sample case 2: you can put 3 boys and 5 girls in the following way: “G#GBGB#G#BG"

Here B means boy student, G means girl student.

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda