一、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.

二、题目分析

        水题,只是做日常工作记录。

三、Java代码

  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5. public static void main(String[] args) {
  6. Scanner cin=new Scanner(System.in);
  7. int n;
  8. int [][] arr;
  9. while((n=cin.nextInt())!=0){
  10. int sum=0;
  11. int day=0;
  12. arr=new int [n][2];
  13. for(int i=0;i<n;i++){
  14. for(int j=0;j<2;j++){
  15. arr[i][j]=cin.nextInt();
  16. }
  17. if((arr[i][0]+arr[i][1])>sum){
  18. sum=(arr[i][0]+arr[i][1]);
  19. day=i+1;
  20. }
  21. }
  22. if(sum > 8){
  23. System.out.println(day);
  24. }else{
  25. System.out.println(0);
  26. }
  27. }
  28. }
  29. }

版权声明:本文为博主原创文章,未经博主允许不得转载。

Poj2656(水题)的更多相关文章

  1. HDOJ 2317. Nasty Hacks 模拟水题

    Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Tota ...

  2. ACM :漫漫上学路 -DP -水题

    CSU 1772 漫漫上学路 Time Limit: 1000MS   Memory Limit: 131072KB   64bit IO Format: %lld & %llu Submit ...

  3. ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)

    1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 154  Solved: 112[ ...

  4. [poj2247] Humble Numbers (DP水题)

    DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...

  5. gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,

    1195: 相信我这是水题 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 821  Solved: 219 Description GDUT中有个风云人 ...

  6. BZOJ 1303 CQOI2009 中位数图 水题

    1303: [CQOI2009]中位数图 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2340  Solved: 1464[Submit][Statu ...

  7. 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题

    B - 大还是小? Time Limit:5000MS     Memory Limit:65535KB     64bit IO Format: Description 输入两个实数,判断第一个数大 ...

  8. ACM水题

    ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...

  9. CF451C Predict Outcome of the Game 水题

    Codeforces Round #258 (Div. 2) Predict Outcome of the Game C. Predict Outcome of the Game time limit ...

随机推荐

  1. iOS Base64加密

    1.Base64编码说明 Base64编码要求把3个8位字节(3*8=24)转化为4个6位的字节(4*6=24),之后在6位的前面补两个0,形成8位一个字节的形式. 如果剩下的字符不足3个字节,则用0 ...

  2. Python菜鸟之路:Python基础-内置函数补充

    常用内置函数及用法: 1. callable() def callable(i_e_, some_kind_of_function): # real signature unknown; restor ...

  3. Python学习笔记_Python基础

    Python 基础 语句和语法 凝视 继续 代码组 代码的缩进 在一行书写多个语句 模块 变量赋值 赋值操作符 增量赋值 多重赋值 多元赋值 python编写的基本风格 模块的结构和布局 内存管理 变 ...

  4. nginx-gridfs的安装

    mongodb中gridfs适合存放视频和高清图片等等超大文件(小的文件建议不要存在mongodb中): 下面是在centos下配置nginx来訪问mongodb中的mp4文件: 1:安装nginx- ...

  5. 使用JSTL在页面前的空行怎么去除?

    解决的方法是:在每个JSP的头上加上一段代码   <%@ page trimDirectiveWhitespaces="true" %>

  6. 如何禁止eclipse对js文件的校验(building validate)

    在项目(project)上点击右键,依次选择1.Select Properties -> JavaScript -> Include Path2.Select Source tab. ( ...

  7. NeurIPS2018: DropBlock: A regularization method for convolutional networks

    NIPS 改名了!改成了neurips了... 深度神经网络在过参数化和使用大量噪声和正则化(如权重衰减和 dropout)进行训练时往往性能很好.dropout 广泛用于全连接层的正则化,但它对卷积 ...

  8. var妙用

    var广泛使用其实也有用的.比如在一些不太确定类型的地方 (比如要区分int/uint/long/double的时候),用泛型太牛刀而不用又觉得不灵活的时候,其实是比较推荐var的比如设计某种类的时候 ...

  9. zookeeper学习与实战(二)集群部署

    上一篇介绍了单机版zookeeper安装,这种情况一般用于开发测试.如果是生产环境建议用分布式集群部署,防止单点故障,增加zookeeper服务的高可用. [环境介绍]       三台机器:192. ...

  10. P1393 动态逆序对

    题目 P1393 动态逆序对 做题前写篇博客是个好方法 做法 题目规定仅有删除,给每个位置标个号,逆序对+时间轴,显然这是个三维偏序 很久没做过\(cdq\)了,就当模板题讲一下: 按删除的先后顺序为 ...