P26924 [AtCoder] Common Coupons
NOI
题目描述

Problem Description

The convenience store "Runrun Mart" currently sells $ N $ items. The price of the $ i $-th item is $ P_i $ yen, and its utility is $ U_i $ points.

Additionally, an event is being held where coupons are distributed according to the following rules:

  • For every $ 100 $ yen spent, $ 1 $ coupon worth $ 20 $ yen is given. (Fractional amounts less than $ 100 $ yen are truncated.)

With $ 10^{100} $ yen in your possession, you can choose to buy any number of these items (including zero). However, you cannot buy the same item more than once.
Let the total price of the purchased items be $ Q $ yen, the total utility be $ T $ points, and the total face value of the received coupons be $ R $ yen. Define the shopping score $ S $ as $ S = T - Q + R $.
Find the maximum value of $ S $.

Input Format

The input is given from the standard input in the following format:

$ N $ $ P_1 $ $ U_1 $ $ P_2 $ $ U_2 $ $\vdots$ $ P_N $ $ U_N $

Output Format

Output the answer.

Sample Input and Output

Sample Input #1

3
50 40
30 29
60 55

Sample Output #1

5

Sample Input #2

1
652 175

Sample Output #2

0

Sample Input #3

10
859 346
669 705
344 425
693 747
24 808
462 344
930 67
878 35
906 253
531 832

Sample Output #3

1696

Notes/Hints

Constraints

  • All inputs are integers.
  • $1 \le N \le 10^5$
  • $1 \le P_i, U_i \le 10^4$ $(1 \le i \le N)$

Sample Explanation 1

For example, buying the 1st and 3rd items results in a total price of $ 110 $ yen, a total utility of $ 95 $ points, and a total face value of received coupons of $ 20 $ yen. The shopping score is $ 95 - 110 + 20 = 5 $. The score cannot be increased beyond this.

Sample Explanation 2

It might be optimal to not purchase any items at all.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 50 40 30 29 60 55
样例输出
5