Practice

* Author:* Ritvik

*Ritvik*

**Tester:***Ritvik*

**Editorialist:**# DIFFICULTY:

EASY

# PREREQUISITES:

Strings, Math

# PROBLEM:

To find the total score of a player who plays * N* balls based on hits and misses and bonus.

# QUICK EXPLANATION:

Given number of balls * N*, the total score is figured based on hits and misses adding the bonus if at least

*hits have been scored.*

**N/2**# EXPLANATION:

A player plays * N* balls and on every ball he can either hit the ball or miss it. For every hit he gets one run but loses one run in the total score if miss the ball. Also, if he hit at least

*balls, he gets a bonus of*

**N/2***runs in his total score. The problem is to find out the total score.*

**N/2**# SOLUTION:

## Setter's Solution

```
#include <iostream>
using namespace std;
int main() {
int n, i, score = 0, hits = 0;
cin >> n;
char play[n];
for (i = 0; i < n; i++) {
cin >> play[i];
if (play[i] == 'H') {
hits++;
score++;
} else {
score--;
}
}
if (hits >= n / 2) {
score += (n / 2);
}
cout << score << endl;
return 0;
}
```