1282: [NOIP2004] Unhappy Jinjin T1

topic description

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

enter

The input includes seven rows of data, representing the schedule from Monday to Sunday. Each line includes two non-negative integers less than 10, separated by a space, which respectively represent the time when Jinjin attends school and the time when her mother arranges her to attend class.

output

The output consists of one line, which contains only one number. If you are not unhappy, output 0, if you are, output the most unhappy day of the week (use 1, 2, 3, 4, 5, 6, 7 to represent Monday, Tuesday, Wednesday, Thursday, Friday, week Saturday, Sunday). If there are two or more days with the same degree of unhappiness, then output the day with the most preceding time.

sample input

5 3

6 2

7 2

5 3

5 4

0 4

0 6

sample output

3

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int s1,s2;
    int day=0;
    int max=8;
    int i;
    for(i=1;i<=7;i++)
    {
        cin>>s1>>s2;
        if(s1+s2>max)
        {
            max=s1+s2;
            day=i;
        }
    }
    if(max>8)    cout<<day;
    else    cout<<"0";
    return 0;
}

Guess you like

Origin blog.csdn.net/qiuweichen1215/article/details/129288037