P1085 [NOIP 2004 Junior] Unhappy Jinjin

Description

Jinjin has started middle school. Her mom thinks she should study harder, so besides going to school, Jinjin also has to attend various review classes that her mom signed her up for. In addition, each week her mom sends her to study recitation, dance, and piano. However, if Jinjin has more than eight hours of classes in a day, she will be unhappy, and the longer she studies, the more unhappy she becomes. Assume Jinjin will not be unhappy for other reasons, and her unhappiness does not carry over to the next day. Please check Jinjin’s schedule for next week and determine whether she will be unhappy; if so, on which day she will be the most unhappy.

Input Format

The input consists of $7$ lines, representing Monday through Sunday. Each line contains two non-negative integers less than $10$, separated by a space, indicating the hours Jinjin spends in school and the hours in the classes arranged by her mother.

Output Format

Output a single integer. Output $0$ if she will not be unhappy; otherwise, output the day of the week on which she is the most unhappy (use $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 degree of unhappiness, output the earliest one.

Explanation/Hint

NOIP 2004 Junior Problem 1. - 2021-10-27: Added a hack testdata set. - 2022-06-05: Added another hack testdata set. Translated by ChatGPT 5