본문 바로가기
카테고리 없음

백준 #2738 2023-08-02

by 하타라시 2023. 8. 2.

내가 바분건지 설명이 불친절한건지,,,,,

다른사람들은 아무튼 잘알아먹는갑다...

 

 

이게 제가 이해한 내용임당.. 그렇다면 이젠 쉽게 풀수이따..

 

StringBuilder stringBuilder = new StringBuilder(); 
    //행열 개수
    string[] count = Console.ReadLine().Split();

    int row = int.Parse(count[0]);
    int col = int.Parse(count[1]);

    int[,] arr = new int[row,col];
    //값 설정
    for(int x = 0; x < row; x++) {
        string[] put = Console.ReadLine().Split();
        for(int y = 0; y < col; y++
            arr[x,y] = int.Parse(put[y]);
    }

    //더하고
    for(int x = 0; x < row; x++) {
        string[] put = Console.ReadLine().Split();
        for(int y = 0; y < col; y++
            arr[x,y] += int.Parse(put[y]);
    }
    //StringBuilder를 통하여 값출력
    for(int x = 0; x < row; x++) {
        for(int y = 0; y < col; y++
            stringBuilder.Append(arr[x,y] + " ");
    
        stringBuilder.Append("\n");
    }

    Console.Write(stringBuilder);

뭔진 몰라도 StringBuilder로 값출력하고 2차원배열 2개를 쓴거에서 한개만 쓰는형태로 바꿨더니 메모리와 시간소요가 줄어들었다.

처음

위 코드로 바꾼뒤

같은 코드인데 96 나오고 언젠 72고 기준은 모르겠지만 ,,, 아무튼 확연한 차이가 있는것을 확인함