File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
weekly/week02/BOJ_15486_퇴사2 Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change 1+ package week02 .BOJ_15486_퇴사2 ;
2+
3+ import java .util .*;
4+ import java .lang .*;
5+ import java .io .*;
6+
7+ class BOJ15486 {
8+ public static void main (String [] args ) throws IOException {
9+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
10+ int N = Integer .parseInt (br .readLine ());
11+ int [] T = new int [N ];
12+ int [] P = new int [N ];
13+ for (int i = 0 ; i < N ; i ++) {
14+ StringTokenizer st = new StringTokenizer (br .readLine ());
15+ int t = Integer .parseInt (st .nextToken ());
16+ int p = Integer .parseInt (st .nextToken ());
17+ T [i ] = t ;
18+ P [i ] = p ;
19+ }
20+
21+ int max = 0 ;
22+ int [] dp = new int [N + 1 ];
23+ for (int i = 0 ; i < N ; i ++) {
24+ max = Math .max (dp [i ], max );
25+ if (i + T [i ] <= N ) { //기간 초과 제외
26+ dp [i + T [i ]] = Math .max (P [i ] + max , dp [i + T [i ]]);
27+ }
28+ }
29+
30+ System .out .println (Math .max (dp [N ], max ));
31+ }
32+ }
You can’t perform that action at this time.
0 commit comments