Saturday, October 17, 2015

폭탄돌리기

 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
import java.util.*;

public class Main {

 public static void main(String[] args) {
  // TODO Auto-generated method stub
  
  Scanner sc = new Scanner(System.in);
  
  int K = sc.nextInt();
  int N = sc.nextInt();
  
  int[] timeArray = new int[N];
  char[] answerArray = new char[N];
  
  for(int i=0 ; i<N ; i++){
   timeArray[i] = sc.nextInt();
   String s = sc.next();
   answerArray[i] = s.charAt(0);
  }

  int timeAnswerIdx = 0;
  int timer = 0;
  
  int i = K;
  for(;;){
   
   if(timeAnswerIdx > N-1){
    break;
   }
   
   int currentTime = timeArray[timeAnswerIdx];
   char currentAnswer = answerArray[timeAnswerIdx];
   
   timeAnswerIdx++;
   
   timer += currentTime;
   
   if(timer > 210){
    break;
   }
   
   if(currentAnswer =='T'){
    i++;
   }
   
   if(i == 9){
    i = 1;
   }
   
  }
  
  System.out.println(i);
  
 }

}

No comments:

Post a Comment