博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 2656 Unhappy Jinjin(我的水题之路——不开心的学习日)
阅读量:4069 次
发布时间:2019-05-25

本文共 2586 字,大约阅读时间需要 8 分钟。

Unhappy Jinjin
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 8985   Accepted: 6619

Description

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.

Input

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.

Output

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.

Sample Input

75 36 27 25 35 40 40 614 40

Sample Output

30

Hint

Here is a sample solution of this problem using C language: 
#include 
int main(){ while(1) { int i, n; int maxday, maxvalue = -1; scanf("%d", &n); if (n == 0) break; for (i = 1; i <= n; i++) { int a, b; scanf("%d%d", &a, &b); if (a + b > maxvalue) { maxvalue = a + b; maxday = i; } } if (maxvalue <= 8) printf("0\n"); else printf("%d\n", maxday); } return 0;}

Source

Jinjin要学习N天,学习时间分为学校时间和补课时间,如果Jinjin某天学习了超过八小时(>= 8),则Jinjin会不开心,如果他有过不开心,那么求他学习时间最长的一天(从1开始),如果有几天学习时间都最长,则输出最早的一天;如果Jinjin学习时间小于等于八小时,则输出0。
模拟。
代码(1AC):
#include 
#include
#include
int main(void){ int i, days; int max; int first, second; int flag; while (scanf("%d", &days), days != 0){ max = -1; flag = 0; for (i = 0; i < days; i++){ scanf("%d%d", &first, &second); if (first + second > 8 && max < first + second){ flag = i + 1; max = first + second; } } printf("%d\n", flag); } return 0;}

转载地址:http://gooji.baihongyu.com/

你可能感兴趣的文章
OS + Unix IBM Aix basic / topas / nmon / filemon / vmstat / iostat / sysstat/sar
查看>>
monitorServer nagios / cacti / tivoli / zabbix / SaltStack
查看>>
my ReadMap subway / metro / map / ditie / gaotie / traffic / jiaotong
查看>>
OS + Linux DNS Server Bind
查看>>
web test flow
查看>>
web test LoadRunner SAP / java / Java Vuser / web_set_max_html_param_len
查看>>
OS + UNIX AIX command
查看>>
OS + UNIX AIX performance
查看>>
OS + UNIX AIX Tools
查看>>
my ReadBook_liutongjingjixue / circulation economics
查看>>
my ReadBook_wangluoyingxiaoyucehua / network marketing / wangluoyingxiao
查看>>
db base database
查看>>
监控服务器端口,Down掉会自动重启,并发送邮件 Linux Shell
查看>>
Git提交错误:RPC failed; result=22, HTTP code = 411
查看>>
Druid使用ConfigFilter
查看>>
Elicpse使用技巧-打开选中文件文件夹或者包的当前目录
查看>>
eclips 运行项目内存不足的解决方案
查看>>
linux 挂载盘阵 smb
查看>>
漫谈 JAVA程序员、架构师、项目经理
查看>>
OPC品质类型
查看>>