**PROBLEM LINK**:

Practice

Contest, div. 1

Contest, div. 2

**Author:** Abhishek Pandey

**Tester:** Ildar Gainullin

**Editorialist:** Oleksandr Kulkov

**DIFFICULTY**:

CAKEWALK

**PREREQUISITES**:

None

**PROBLEM**:

You’re given N pairs of integers (p_i, s_i) where 1 \leq p_i \leq 11. For each p_i<9 calculate maximum number of s_i with this p_i and output the sum of these numbers.

**QUICK EXPLANATION**:

You should basically do what’s written in the statement.

**EXPLANATION**:

Maintain array mx with maximum scores for each problem and output the sum of first 9 elements.

```
void solve() {
int n;
cin >> n;
vector<int> mx(11);
for(int i = 0; i < n; i++) {
int p, s;
cin >> p >> s;
mx[p] = max(mx[p], s);
}
cout << accumulate(begin(mx), begin(mx) + 9, 0LL) << endl;
}
```

**AUTHOR’S AND TESTER’S SOLUTIONS**:

Author’s solution can be found here.

Tester’s solution can be found here.

Editorialist’s solution can be found here.