File tree Expand file tree Collapse file tree 2 files changed +33
-2
lines changed
Expand file tree Collapse file tree 2 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( "fs" ) ;
2+ const filePath = process . platform === "linux" ? "/dev/stdin" : "./서정우/input.txt" ;
3+ const input = fs . readFileSync ( filePath ) . toString ( ) . trim ( ) . split ( "\n" ) ;
4+
5+ const N = Number ( input [ 0 ] ) ;
6+
7+ const lines = input . slice ( 1 ) ;
8+ const totalMinutes = lines . map ( ( time ) => {
9+ const [ H , M ] = time . split ( ":" ) . map ( Number ) ;
10+ const totalMinutes = H * 60 + M ;
11+ return totalMinutes % 720 ;
12+ } ) ;
13+
14+ let minClocks = N ;
15+
16+ for ( let r = 0 ; r < 720 ; r ++ ) {
17+ const clockTimes = new Set ( ) ;
18+
19+ for ( let i = 0 ; i < N ; i ++ ) {
20+ const clockTime = ( totalMinutes [ i ] - ( ( i * r ) % 720 ) + 720 ) % 720 ;
21+
22+ clockTimes . add ( clockTime ) ;
23+ }
24+
25+ minClocks = Math . min ( minClocks , clockTimes . size ) ;
26+ }
27+ console . log ( minClocks ) ;
Original file line number Diff line number Diff line change 1- 1
2- $
1+ 5
2+ 03:05
3+ 12:40
4+ 03:25
5+ 03:25
6+ 01:10
You can’t perform that action at this time.
0 commit comments