Skip to content

Commit 7694774

Browse files
committed
[D2] Title: 두 개의 숫자열, Time: 79 ms, Memory: 24,960 KB -BaekjoonHub
1 parent ea747ed commit 7694774

File tree

2 files changed

+68
-0
lines changed

2 files changed

+68
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# [D2] 두 개의 숫자열 - 1959
2+
3+
[문제 링크](https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AV5PpoFaAS4DFAUq)
4+
5+
### 성능 요약
6+
7+
메모리: 24,960 KB, 시간: 79 ms, 코드길이: 1,619 Bytes
8+
9+
### 제출 일자
10+
11+
2025-10-03 18:14
12+
13+
14+
15+
> 출처: SW Expert Academy, https://swexpertacademy.com/main/code/problem/problemList.do
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import java.util.*;
2+
import java.io.*;
3+
4+
class Solution
5+
{
6+
public static void main(String args[]) throws Exception
7+
{
8+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
9+
StringBuilder sb = new StringBuilder();
10+
int T = Integer.parseInt(br.readLine());
11+
12+
for(int i=1; i<=T; i++){
13+
StringTokenizer st = new StringTokenizer(br.readLine());
14+
int N = Integer.parseInt(st.nextToken());
15+
int M = Integer.parseInt(st.nextToken());
16+
17+
int[] A = new int[N];
18+
int[] B = new int[M];
19+
20+
st = new StringTokenizer(br.readLine());
21+
for(int j=0; j<N; j++){
22+
A[j] = Integer.parseInt(st.nextToken());
23+
}
24+
25+
st = new StringTokenizer(br.readLine());
26+
for(int j=0; j<M; j++){
27+
B[j] = Integer.parseInt(st.nextToken());
28+
}
29+
30+
int max = 0;
31+
if(N>=M){
32+
for(int j=0; j<=N-M; j++){
33+
int sum = 0;
34+
for(int z=0; z<M; z++){
35+
sum += B[z] * A[z+j];
36+
}
37+
max = Math.max(max, sum);
38+
}
39+
}else{
40+
for(int j=0; j<=M-N; j++){
41+
int sum = 0;
42+
for(int z=0; z<N; z++){
43+
sum += A[z] * B[z+j];
44+
}
45+
max = Math.max(max, sum);
46+
}
47+
}
48+
49+
sb.append("#" + i + " " + max + "\n");
50+
}
51+
System.out.println(sb);
52+
}
53+
}

0 commit comments

Comments
 (0)