Title DescriptionDescription Jinjin on the junior high school. Mother think Jinjin should study harder, so jinjin in addition to school, but also to participate in the mother for her to enroll in the various subjects review class. In addition, every day mother will send her to learn recitation, dance and piano. But Jinjin would be unhappy if he had been in school for more than eight hours a day, and the longer he would be unhappy.
This time, unlike the first question in the NOIp2004 group, it is assumed that Jinjin will not be unhappy with other things, but her unhappy will continue until the next day. Please help to check the Jinjin after the N-day schedule, to see if the next N days she will not be happy (method of calculation: With the amount of unhappy yesterday plus the total number of classes today minus 8 after the count as today's unhappy degree); after the output n days after the end of the unhappy degree and how much.
input/output format input/output
Input Format:
Line 1th: a number n
Line 2nd ~ n+1: Two numbers per line, indicating the time of school and extracurricular classes
output Format:
A number, which n days after the unhappy degree and
input and Output sample sample Input/output
sample Test point # #
Input Sample:
7
5 3
6 2
9 |
5 3
5 4
0 4
0 6
Sample output:
-2
Idea: This question is actually not the array, each time input two number, record the degree of unhappy and unhappy degree and get.
The code is as follows:
1#include <stdio.h>2 intMain ()3 { 4 inta,w=0, n1=0, M,n; 5 intZ; 6scanf"%d",&a); 7 for(z=0; z<a;z++) 8 { 9scanf"%d%d",&m,&N); TenW=w+m+n+n1-8; OneN1=m+n+n1-8; A } -printf"%d\n", W); - return 0; the}
Rokua-Unhappy Jinjin (upgraded version)-array