[NOIP2004 Popularization Team] Unhappy Jinjin

Topic link

Description of the topic
Tsujin has gone to junior high school. Mother thinks that Jinjin should study harder, so in addition to going to school, Jinjin also participates in various review classes that her mother has signed up for. In addition, every week her mother will send her to learn recitation, dance and piano. But Jinjin will be unhappy if he attends classes for more than eight hours a day, and the longer he attends, the more unhappy. Assume that Jinjin will not be unhappy because of other things, and her unhappiness will not last until the next day. Please help to check Jinjin’s schedule for next week and see if she will be unhappy next week; if so, which day will be the most unhappy.

Input format The
input includes 7 rows of data, which respectively represent the schedule from Monday to Sunday. Each line contains two non-negative integers less than 1010, separated by a space, indicating respectively the time Jinjin is in school and the time her mother arranges for her to go to class.

Output format
A number. If it is not unhappy, output 0, if it will output the most unhappy day of the week (use 1, 2, 3, 4, 5, 6, 7 to indicate Monday, Tuesday, Wednesday, Thursday, Friday, and week respectively) Saturday, Sunday). If there are two days or more of the same level of unhappiness, the first day is output.

Code:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    
    
	int a, b ,count = 0, max = 0;
	for(int i = 1; i <= 7; i++)
	{
    
    
		cin >> a >> b;
		if(a + b > 8 && a + b > max)
		{
    
    
			max = a + b;
			count = i;
		}
	}
	cout << count;
	return 0;
}

Guess you like

Origin blog.csdn.net/qq_44826711/article/details/113738723