Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

192
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda