File tree Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Expand file tree Collapse file tree 4 files changed +51
-0
lines changed Original file line number Diff line number Diff line change 62
62
| 23 | | [ Baekjoon-15683 ๊ฐ์] ( ./src/Simulation/P15683 ) | |
63
63
| 24 | | [ SWEA-4014 ํ์ฃผ๋ก ๊ฑด์ค] ( ./src/Simulation/swea4014 ) | ์ผ์ฑ SW ์ญ๋ ํ
์คํธ ๊ธฐ์ถ |
64
64
| 25 | | [ Baekjoon-17779 ๊ฒ๋ฆฌ๋งจ๋๋ง 2] ( ./src/Simulation/P17779 ) | |
65
+ | 26 | | [ Baekjoon-2564 ๊ฒฝ๋น์] ( ./src/Simulation/P2564 ) | |
65
66
66
67
## String
67
68
Original file line number Diff line number Diff line change
1
+ package Simulation .P2564 ;
2
+
3
+ import java .io .*;
4
+ import java .util .*;
5
+
6
+ public class Main {
7
+
8
+ static int W , H , N , sum ;
9
+ static int [] pos ;
10
+
11
+ public static void main (String [] args ) throws Exception {
12
+ System .setIn (new FileInputStream ("src/Simulation/P2564/input.txt" ));
13
+ BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
14
+ StringTokenizer st = new StringTokenizer (br .readLine ());
15
+
16
+ W = Integer .parseInt (st .nextToken ());
17
+ H = Integer .parseInt (st .nextToken ());
18
+ N = Integer .parseInt (br .readLine ());
19
+
20
+ pos = new int [N +1 ];
21
+ for (int i = 0 ; i <= N ; i ++) {
22
+ st = new StringTokenizer (br .readLine ());
23
+ int d = Integer .parseInt (st .nextToken ());
24
+ int k = Integer .parseInt (st .nextToken ());
25
+ if (d == 1 ) pos [i ] = k ;
26
+ else if (d == 2 ) pos [i ] = 2 *W +H -k ;
27
+ else if (d == 3 ) pos [i ] = 2 *(W +H )-k ;
28
+ else pos [i ] = W +k ;
29
+ }
30
+
31
+ int x = pos [N ];
32
+ for (int i = 0 ; i < N ; i ++) {
33
+ int dist = Math .abs (x -pos [i ]);
34
+ sum += Math .min (dist , 2 *(W +H )-dist );
35
+ }
36
+
37
+ System .out .println (sum );
38
+ }
39
+ }
Original file line number Diff line number Diff line change
1
+ ## [ baekjoon-2564] ๊ฒฝ๋น์
2
+
3
+ ![ image] ( https://user-images.githubusercontent.com/22045163/114589793-fa307400-9cc2-11eb-886f-2d3a39ab8772.png )
4
+
5
+ ![ image] ( https://user-images.githubusercontent.com/22045163/114589833-03214580-9cc3-11eb-93b0-27e94d169894.png )
Original file line number Diff line number Diff line change
1
+ 10 5
2
+ 3
3
+ 1 4
4
+ 3 2
5
+ 2 8
6
+ 2 3
You canโt perform that action at this time.
0 commit comments