File tree Expand file tree Collapse file tree 2 files changed +29
-1
lines changed
Expand file tree Collapse file tree 2 files changed +29
-1
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const filePath =
3+ process . platform === "linux" ? "/dev/stdin" : "./서정우/input.txt" ;
4+ const input = fs
5+ . readFileSync ( filePath )
6+ . toString ( )
7+ . trim ( )
8+ . split ( "\n" )
9+ . map ( ( el ) => el . trim ( ) ) ;
10+
11+ const N = Number ( input [ 0 ] ) ;
12+ const lostHealthPerPeople = input [ 1 ] . split ( " " ) . map ( Number ) ;
13+ const earnPleasurePerPeople = input [ 2 ] . split ( " " ) . map ( Number ) ;
14+
15+ const dp = Array ( 100 ) . fill ( 0 ) ;
16+
17+ for ( let i = 0 ; i < N ; i ++ ) {
18+ const L = lostHealthPerPeople [ i ] ;
19+ const J = earnPleasurePerPeople [ i ] ;
20+
21+ for ( let h = 99 ; h >= L ; h -- ) {
22+ dp [ h ] = Math . max ( dp [ h ] , dp [ h - L ] + J ) ;
23+ }
24+ }
25+
26+ console . log ( Math . max ( ...dp ) ) ;
Original file line number Diff line number Diff line change 1- 999998999
1+ 12
2+ 1 1 1 1 1 1 1 1 1 1 1 1
3+ 100 100 100 100 100 100 100 100 100 100 100 100
You can’t perform that action at this time.
0 commit comments