小贪心


私信TA

用户名:uq_90082943905

访问量:2461

签 名:

等  级
排  名 5146
经  验 1516
参赛次数 0
文章发表 7
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

 

0.0分

0 人评分

  评论区

Scanner scanner = new Scanner(System.in);
        int n =scanner.nextInt();
        int[] list = new int[n];
        int result = 0;
        for (int i=0;i<n;i++){
          list[i] = scanner.nextInt();
          result = result+list[i];
        }
        int avg=result/n;
        int times=0;
        int[] list_new = new int[n];
        for(int i=0;i<n;i++){
            list_new[i]=list[i]-avg;
        }
        for(int i=0;i<n;i++){
            if(list_new[i]!=0){
                list_new[i+1] +=list_new[i];
                list_new[i]=0;
                times++;
            }
 根据大佬思路改。感谢!
2024-03-08 17:40:31
  • «
  • 1
  • »