-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain1535_안녕.java
44 lines (35 loc) · 1.02 KB
/
Main1535_안녕.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
//BOJ :: 1535 안녕
//2019-03-25
public class Main1535_안녕 {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine()); // 사람 수
int[] L = new int[N]; //체력
int[] J = new int[N]; //기쁨
int[] dp = new int[100];
StringTokenizer st = new StringTokenizer(br.readLine(), " ");
for(int i=0;i<N;i++) {//체력
L[i] = Integer.parseInt(st.nextToken());
}
st = new StringTokenizer(br.readLine(), " ");
for(int i=0;i<N;i++) {//기쁨
J[i] = Integer.parseInt(st.nextToken());
if(L[i]<100) dp[L[i]] = J[i];
}
int ans = 0;
//기쁨 max
for(int i=0;i<N;i++) { //i는 사람 번호
for(int j=0;j<N;j++) {
if(i==j) continue;
if(L[i]+L[j]<100) {
dp[L[i]+L[j]] =dp[L[i]]+dp[L[j]];
ans = ans < dp[L[i]+L[j]]? dp[L[i]+L[j]]:ans;
}
}
}
System.out.println(ans);
}
}