-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbonus.cpp
More file actions
33 lines (26 loc) · 785 Bytes
/
bonus.cpp
File metadata and controls
33 lines (26 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int n;
cin >> n;
string participants;
cin >> participants;
int females = 0, males = 0;
// Count number of females and males
for (char c : participants) {
if (c == 'F') females++;
else males++;
}
// The maximum number of valid teams is the minimum of:
// - the number of females (since each team needs at least one female)
// - the total number of complete teams that can be formed (n / 4)
int max_teams = min(females, n / 4);
cout << max_teams << endl;
}
return 0;
}