LCC ‘21 Contest 5 S2 - Grinding League

View as PDF

Submit solution

Points: 7 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

During the summer holidays, Derek likes to play his favourite video game, League of Legends. Derek plays N days in a row, not because he's hopelessly addicted, but because he wants to climb the ranked ladder. On each day, he wins A matches and loses B matches. He starts with 0 points and winning a match rewards him with 22 points, while losing a game costs Derek 16 points. At the end of the N days, a corrupt admin provides Derek the chance to delete the losses between days X and Y (inclusive). For each of the Q queries in the form X Y, output the total amount of points Derek will have after the selected losses are deleted.

Input Specification

The first line of input contains one integer, N, the number of days he played.

The next N lines contain two integers A and B, representing the wins and losses.

The next line contains one integer, Q, the number of queries to follow.

The next Q lines contain two integers X and Y, representing each of the queries.

Output Specification

For each query, output one integer T, the total amount of points Derek has after the N days.

Contraints

1 \le N,Q \le 500 000
1 \le A,B \le 10
1 \le X \le Y \le N

Sample Input

3
1 2
3 1
2 2
1
2 3

Sample Output

100

Comments

There are no comments at the moment.