POJ 2656 Unhappy Jinjin

阅读: 评论:0

POJ 2656  Unhappy Jinjin

POJ 2656 Unhappy Jinjin

时间限制: 
1000ms
内存限制:
65536kB
描述
Jinjin is a junior school student. Besides the classes in school, Jinjin's mother also arranges some supplementary classes for her. However, if Jinjin studies for more than eight hours a day, she will be unhappy on that day. On any day she gets unhappy, the more time she studies, the unhappier she will be. Now we got Jinjin's class schedule for the next several days and your task is to find out whether she will be unhappy on these days; if she will be unhappy, on which day she will be the unhappiest.
输入
There may be several test cases. In the first line of each test case, there is an integer N (1 <= N <= 7), which represents the number of days you should analyze. Then there comes N lines, each contains two non-negative integers (each smaller than 10). The first integer represents how many hours Jinjin studies at school on the day, and the second represents how many hours she studies in the supplementary classes on the same day.

A case with N = 0 indicates the end of the input, and this case should not be processed.
输出
For each test case, output a line contains a single integer. If Jinjin will always be happy, the integer should be 0; otherwise, the integer should be a positive integer K, which means that Jinjin will be the unhappiest on the K-th day. If the unhappiest day is not unique, just output the earliest one among these unhappiest days.
样例输入
75 36 27 25 35 40 40 614 40
样例输出
30
(1)、源代码: #include <iostream> using namespace std;   int main(){                  int i, n, a, b;                    while (1){                                 cin >> n;                                  if (0 == n)                                                  break ;                                  int mday, mhour = -1;                                  for (i = 1; i <=n ; i++){                                                 cin >> a >> b;                                                  if (a+b > mhour){                                                                 mhour = a+b;                                                                 mday = i;                                                 }                                 }                                  if (mhour <=8)                                                 cout << "0n" ;                                  else                                                 cout << mday << endl;                 }                  return 0; } (2)、可能出错:略 (3)、解题思路:略

转载于:.html

本文发布于:2024-01-28 14:32:04,感谢您对本站的认可!

本文链接:https://www.4u4v.net/it/17064235308094.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:POJ   Jinjin   Unhappy
留言与评论(共有 0 条评论)
   
验证码:

Copyright ©2019-2022 Comsenz Inc.Powered by ©

网站地图1 网站地图2 网站地图3 网站地图4 网站地图5 网站地图6 网站地图7 网站地图8 网站地图9 网站地图10 网站地图11 网站地图12 网站地图13 网站地图14 网站地图15 网站地图16 网站地图17 网站地图18 网站地图19 网站地图20 网站地图21 网站地图22/a> 网站地图23