#P1085. [NOIP 2004 普及组] 不高兴的津津

[NOIP 2004 普及组] 不高兴的津津

Unhappy Jinjin

Problem Source

Luogu P1085

Problem Description

Jinjin has started junior high school. Her mother thinks Jinjin should study harder, so besides school Jinjin also attends various tutoring classes her mother signed her up for. In addition, every week her mother sends her to study recitation, dance and piano. However, if Jinjin has more than 8 hours of class in a single day she becomes unhappy, and the more hours she has, the unhappier she gets. Assume Jinjin never gets unhappy for any other reason, and her unhappiness does not carry over to the next day. Please help check Jinjin's schedule for next week and see whether she will be unhappy; if so, on which day she will be the most unhappy.

Input Format

The input consists of 7 lines of data, representing the schedule from Monday to Sunday. Each line contains two non-negative integers less than 10, separated by a space, representing the time Jinjin spends in school classes and the time her mother arranges for her to take classes, respectively.

Output Format

One number. If she will not be unhappy, output 0; otherwise output the day on which she is the most unhappy (using 1, 2, 3, 4, 5, 6, 7 to denote Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday respectively). If two or more days have the same (highest) level of unhappiness, output the earliest such day.

Sample Input

5 3
6 2
7 2
5 3
5 4
0 4
0 6

Sample Output

3

Hint

NOIP2004 Popularization Group Problem 1.

  • 2021-10-27: added a group of hack data.
  • 2022-06-05: added another group of hack data.