网易笔试第一题?

测试样例自测成功,提交通过率0%,看了半天没发现是哪里有问题...

package ttt.WangYi._1;

import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int cnt = scanner.nextInt();
        int[] scores = new int[cnt];
        for(int i=0; i < cnt; i++){
            scores[i] = scanner.nextInt();
        }

        int queryCnt = scanner.nextInt();
        int[] queryScore = new int[queryCnt];
        for(int i=0; i < queryCnt; i++){
            queryScore[i] = scores[scanner.nextInt()-1];
        }

        Arrays.sort(scores);
        for(int i=0; i < queryCnt; i++){
            double pos  = ((double)Arrays.binarySearch(scores,queryScore[i])/cnt) * 100;
            System.out.println(String.format("%.6f",pos));
        }

    }
}
#网易##笔试题目#
全部评论
笔试第一题n+1-num[i] 就可以百分之百科
点赞 回复 分享
发布于 2019-08-03 16:54
同样情况= = 
点赞 回复 分享
发布于 2019-08-03 17:11
感觉应该是没有考虑成绩重复的情况,下边是我测试的例子 5 100 100 100 100 100 5 1 2 3 4 5 40.000000 40.000000 40.000000 40.000000 40.000000
点赞 回复 分享
发布于 2019-08-03 17:08
点赞 回复 分享
发布于 2019-08-03 17:03
我也是
点赞 回复 分享
发布于 2019-08-03 17:02
心态崩,还有第四题,怎么想都觉得不可能两道都0通过率,然而事实就是😭
点赞 回复 分享
发布于 2019-08-03 17:02
考虑100,100 ,98,97这种样例,这样算出来100是50%,事实上是75%
点赞 回复 分享
发布于 2019-08-03 16:54
心态崩了,我觉得怎么都不可能case 0%.....就很烦
点赞 回复 分享
发布于 2019-08-03 16:49
已经交卷了orz
点赞 回复 分享
发布于 2019-08-03 16:45
我也是
点赞 回复 分享
发布于 2019-08-03 16:44
点赞 回复 分享
发布于 2019-08-03 16:43

相关推荐

评论
点赞
收藏
分享

创作者周榜

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