조영준 ¶
주어진 Test Case로만 테스트를 진행하였습니다.
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int caseSize = scanner.nextInt(); for (int i = 0; i < caseSize; i++) { int caseHeight = scanner.nextInt(); int caseWidth = scanner.nextInt(); int[] columnCost = new int[caseWidth]; int[] columnSum = new int[caseWidth]; for (int j = 0; j < caseHeight; j++) { for (int k = 0; k < caseWidth; k++) { int currentBox = scanner.nextInt(); if (currentBox == 1) { columnCost[k]++; } else { columnSum[k] += columnCost[k]; } } } int caseSum = 0; for (int j = 0; j < caseWidth; j++) { caseSum += columnSum[j]; } System.out.println(caseSum); } scanner.close(); } }