문제 링크 : https://www.swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PzOCKAigDFAUq


문제의 저작권은 SW Expert Academy에 있습니다.



#include <iostream>
 
using namespace std;
 
int main(void) {
    int T, N, M;
    cin >> T;
 
    for(int t_case=0; t_case<T; t_case++) {
        cin >> N >> M;
        int fly[N][N];
        int die = 0;
 
        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                cin >> fly[i][j];
            }
        }
 
        for(int i=0; i<=N-M; i++) {
            for(int j=0; j<=N-M; j++) {
                int temp = 0;
                for(int k=i; k<i+M; k++) {
                    for(int l=j; l<j+M; l++) {
                        temp += fly[k][l];
                    }
                }
                if(die < temp)
                    die = temp;
            }
        }
 
 
        cout << "#" << t_case+1 << " " << die << "\n";
    }
 
    return 0;
}
cs

'C & C++ > SW Expert Academy' 카테고리의 다른 글

SWEA 3750 - Digit sum  (0) 2018.04.28
SWEA 3975 - 승률 비교하기  (0) 2018.04.28
SWEA 1989 - 초심자의 회문 검사  (0) 2018.04.28
SWEA 1986 - 지그재그 숫자  (0) 2018.04.28
SWEA 1983 - 조교의 성적 매기기  (2) 2018.04.28

+ Recent posts