zoukankan      html  css  js  c++  java
  • 201909-2 小明种苹果(续) Java

    思路:
    待补充

    import java.util.*;
    
    public class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int n = sc.nextInt();
            int[][] count = new int[n][1001];
            int size[] = new int[n];
            for(int i = 0; i < n; i++) {
                int m = sc.nextInt();
                size[i] = m;
                for(int j = 0; j < m; j++) {
                    count[i][j] = sc.nextInt();
                }
            }
            
            int[] sum = new int[n];
            int[] del = new int[n];
            int allSum = 0;
            for(int i = 0; i < n; i++) {
                sum[i] = count[i][0];
                for(int j = 1; j < size[i]; j++) {
                    if(count[i][j] > 0) {
                        if(sum[i] != count[i][j]) {
                            del[i] = 1;
                        }
                        sum[i] = count[i][j];
                    }else {
                        sum[i] += count[i][j];
                    }
                    
                }
                allSum += sum[i];
            }
            int delCount = 0;
            int group = 0;
            for(int i = 0; i < n; i++) {
                if(del[i] != 0) {
                    delCount ++;
                    if(i == 0) {
                        if(del[n-1] != 0 && del[i+1] != 0) {
                            group ++;
                        }
                    }else if(i == n-1) {
                        if(del[i-1] != 0 && del[0] != 0) {
                            group ++;
                        }
                    }else {
                        if(del[i-1] != 0 && del[i+1] != 0) {
                            group ++;
                        }
                    }
                }
            }
            System.out.println(allSum+" "+delCount+" "+group);
        }
    }
    
  • 相关阅读:
    会议记录
    周总结
    团队博客
    周总结
    移动端疫情展示
    代码规范
    阅读笔记2
    解决 import numpy as np ModuleNotFoundError: No module named 'numpy'错误
    周总结
    爬取最新疫情数据
  • 原文地址:https://www.cnblogs.com/yu-jiawei/p/12376615.html
Copyright © 2011-2022 走看看