当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2656:Unhappy Jinjin

题目描述
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.
输入样例
7
5 3
6 2
7 2
5 3
5 4
0 4
0 6
1
4 4
0
输出样例
3
0
提示
Here is a sample solution of this problem using C language:
#include <stdio.h>

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;
}

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 NOIP 2004

源链接: POJ-2656

最后修改于 2020-10-29T06:38:25+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536