Skip to content

Commit

Permalink
[D3] Title: 농작물 수확하기, Time: 122 ms, Memory: 21,168 KB -BaekjoonHub
Browse files Browse the repository at this point in the history
  • Loading branch information
sey2 committed Nov 17, 2023
1 parent 97248c9 commit c01eb58
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
15 changes: 15 additions & 0 deletions SWEA/D3/2805. 농작물 수확하기/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# [D3] 농작물 수확하기 - 2805

[문제 링크](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV7GLXqKAWYDFAXB)

### 성능 요약

메모리: 21,168 KB, 시간: 122 ms, 코드길이: 1,172 Bytes

### 제출 일자

2023-11-17 23:36



> 출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Solution {

public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(br.readLine());

int cnt = 1;
while(T-->0) {
int n = Integer.parseInt(br.readLine());
int arr[][] = new int[n][n];

for (int i = 0; i < n; i++) {
String in = br.readLine();
for (int j = 0; j < n; j++) {
arr[i][j] = in.charAt(j) - '0';
}
}

int num = n/2;
boolean reverse = false;
int sum = 0;

for(int i=0; i<n; i++) {
for(int j=num; j<n - num; j++) {
sum += arr[i][j];
}

if(!reverse) num --;
else num++;
if(i == n/2) {
num = 1;
reverse = true;
}

}
System.out.println("#" + cnt++ + " " + sum);
}
}
}

0 comments on commit c01eb58

Please sign in to comment.