U E D R , A S I H C RSS

ACM_ICPC/Problems/6500


풀이

조영준

주어진 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();
	}
}
Valid XHTML 1.0! Valid CSS! powered by MoniWiki
last modified 2021-02-07 05:22:21
Processing time 0.0071 sec