小明种苹果(续)
作者:互联网
问题描述: |
|
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); int m, current, temp, sum = 0, cutTreeNum = 0, t3Num = 0; boolean[] vis = new boolean[n + 5]; for (int i = 0; i < n; i++) { m = scanner.nextInt(); current = scanner.nextInt(); for (int j = 1; j < m; j++) { temp = scanner.nextInt(); if (temp <= 0) { current += temp; } else if (current > temp) { current = temp; vis[i] = true; } } sum += current; } for (int i = 0; i < n; i++) { if (vis[i]) cutTreeNum++; if (vis[(i - 2 + n) % n] && vis[(i - 1 + n) % n] && vis[i]) t3Num++; } System.out.println(sum + " " + cutTreeNum + " " + t3Num); } }
标签:scanner,temp,小明种,int,++,vis,苹果,nextInt 来源: https://www.cnblogs.com/pw126046/p/11874706.html