Java题目,总是说输出为空

在eclipse中运行没问题啊,求大神指点
package data;
import java.util.*;
public class HuaweiTest {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String num=sc.nextLine();
        int stuNum=Integer.parseInt(num.split(" ")[0]);
        int actNum=Integer.parseInt(num.split(" ")[1]);
        int[] scores=new int[stuNum];
        for(int i=0;i<actNum+1;i++){
            String input=sc.nextLine();
            if(i==0){
                String[] scoresStrArray=input.split(" ");
                for(int j=0;j<stuNum;j++){
                    scores[j]=Integer.parseInt(scoresStrArray[j]);
                }
                continue;
            }
            String[] actArray=input.split(" ");
            int num1=Integer.parseInt(actArray[1]);
            int num2=Integer.parseInt(actArray[2]);
            if(actArray[0].equals("Q")){
                int max=0;
                int mmax=num1>num2?num1:num2;
                int mmin=num1<num2?num1:num2;
                for(int j=mmin-1;j<mmax;j++){
                    if(scores[j]>max){
                        max=scores[j];
                    }
                }
                System.out.println(max);
            }
            else if(actArray[0].equals("U")){
                scores[num1-1]=num2;
            }
        }
        sc.close();
    }
}
您的代码已保存
答案错误:您提交的程序没有通过所有的测试用例
case通过率为10.00%

用例:
9 10
28 49 11 35 40 17 57 4 6
Q 9 9
U 9 79
Q 9 5
Q 4 8
U 2 27
U 8 40
U 4 77
U 7 71
U 4 44
U 8 51

对应输出应该为:

6
79
57

你的输出为:
空.请检查一下你的代码,有没有循环输入处理多个case

全部评论
这题有多组数据,不是一组
点赞 回复 分享
发布于 2019-04-03 10:27
哈哈,华为的真题吧!
点赞 回复 分享
发布于 2019-04-03 10:27

相关推荐

04-25 18:13
五邑大学 Java
后来123321:大二两段实习太厉害了,我现在大二连面试都没有
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务