-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[D3] Title: 농작물 수확하기, Time: 122 ms, Memory: 21,168 KB -BaekjoonHub
- Loading branch information
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |