File tree Expand file tree Collapse file tree 2 files changed +36
-1
lines changed
Expand file tree Collapse file tree 2 files changed +36
-1
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const { kill } = require ( "process" ) ;
3+ const filePath = 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 , X , Y ] = input [ 0 ] . split ( " " ) . map ( Number ) ;
12+ const sandwiches = input [ 1 ] . split ( " " ) . map ( Number ) ;
13+
14+ // N = sandwiches count
15+ // X = 최소
16+ // Y = 최대
17+
18+ let kkini = 0 ;
19+ let left = 0 ;
20+
21+ sandwiches . forEach ( ( sandwich ) => {
22+ if ( X <= sandwich ) {
23+ const kkinies = Math . floor ( sandwich / X ) ;
24+ const maxEat = kkinies * Y ;
25+ const eaten = Math . min ( sandwich , maxEat ) ;
26+ const wasted = sandwich - eaten ;
27+ left += wasted ;
28+ kkini += kkinies ;
29+ } else {
30+ left += sandwich ;
31+ }
32+ } ) ;
33+ console . log ( kkini ) ;
34+ console . log ( left ) ;
Original file line number Diff line number Diff line change 1- 10 10
1+ 6 10 12
2+ 11 10 17 5 23 28
You can’t perform that action at this time.
0 commit comments