Tuesday, September 15, 2015

참외밭 Wrong Answer

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
import java.io.IOException;

import java.util.Scanner;

public class Main
{

 public static void main(String[] arg) throws IOException
 {

  int[][] a = new int[6][2];

  int K, sum = 0;

  Scanner sc = new Scanner(System.in);

  // 입력받는부분

  K = sc.nextInt();

  for (int i = 0; i < 6; i++) {

   a[i][0] = sc.nextInt();
   a[i][1] = sc.nextInt();

  }
  // 여기서부터작성

  
  int[] eastWest  = new int[3];
  int[] southNorth  = new int[3];

  int eWIdx = 0;
  int sNIdx = 0;
  for (int i = 0; i < 6; i++) {
   if(a[i][0] == 1 || a[i][0] == 2){
    eastWest[eWIdx++] = a[i][1];
   }
   if(a[i][0] == 3 || a[i][0] == 4){
    southNorth[sNIdx++] = a[i][1];
   }
  }
  
  int ewBig = 0;
  int ewBigIdx = 0;
  int ewSmallIdx = 0;
  for(int i = 0;i < eastWest.length; i++){
   if(ewBig < eastWest[i]){
    ewBig = eastWest[i];
    ewBigIdx = i;
   }
  }
  
  if(ewBigIdx == 0){
   ewSmallIdx = 1;
  }else if(ewBigIdx == 1){
   ewSmallIdx = 2;
  }else if(ewBigIdx == 2){
   ewSmallIdx = 0;
  }
  
  int ewBigValue = eastWest[ewBigIdx];
  int ewSmallValue = eastWest[ewSmallIdx];
  
//////////////////////////////////////////////////////////////  
  
  int snBig = 0;
  int snBigIdx = 0;
  int snSmallIdx = 0;
  for(int i = 0;i < southNorth.length; i++){
   if(snBig < southNorth[i]){
    snBig = southNorth[i];
    snBigIdx = i;
   }
  }
  
  if(snBigIdx == 0){
   snSmallIdx = 2;
  }else if(snBigIdx == 1){
   snSmallIdx = 0;
  }else if(snBigIdx == 2){
   snSmallIdx = 1;
  }
  
  int snBigValue = southNorth[snBigIdx];
  int snSmallValue = southNorth[snSmallIdx];
  
//  System.out.println(ewBigValue+" "+ewSmallValue);
//  System.out.println(snBigValue+" "+snSmallValue);
  
  sum = ((ewBigValue * snBigValue) - (ewSmallValue * snSmallValue)) * K; 
  // 출력하는부분
  System.out.println(sum);

  sc.close();

 }

}

No comments:

Post a Comment