#P1534. 不高兴的津津(升级版)
不高兴的津津(升级版)
Description
Jinjin has entered middle school. Her mom thinks she should study harder, so besides attending school, Jinjin also has to go to the review classes her mom enrolled her in. In addition, every day her mom takes her to learn recitation, dance, and piano. However, if Jinjin studies for more than eight hours in a day, she becomes unhappy, and the longer she studies, the more unhappy she becomes.
Different from the first problem of NOIp2004 Junior: assume Jinjin will not be unhappy because of other things, but her unhappiness (and of course her happiness) will carry over to the next day. Please check Jinjin’s schedule for the next days and determine whether she will be unhappy during these days (calculation method: use yesterday’s unhappiness degree plus today’s total class time minus to obtain today’s unhappiness degree); output the sum of the unhappiness degrees after these days.
Input Format
The first line contains a single integer .
From line to line , each line contains two integers, representing the school time and the extracurricular tutoring time for that day.
Output Format
A single integer: the sum of the unhappiness degrees after these days.
7
5 3
6 2
7 2
5 3
5 4
0 4
0 6
-2
Hint
Constraints
For all testdata, the school time and the class time each do not exceed , and their sum does not exceed , and .
Translated by ChatGPT 5
京公网安备 11011102002149号