📍 Culture shock

https://www.acmicpc.net/problem/25277

 

 

 

토르가 he, she, him, her을 말한 횟수를 세면 된다.

 

 

 

✨ 전체코드 ✨

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader sc = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(sc.readLine());
        String[] electricalShocks = {"he", "she", "him", "her"};

        int N = Integer.parseInt(st.nextToken());
        String[] array = new String[N];

        st = new StringTokenizer(sc.readLine());
        int cnt = 0;
        
        for(int i=0; i<N; i++){
            array[i] = st.nextToken();
            for(int j=0; j<electricalShocks.length; j++){
                if(array[i].equals(electricalShocks[j])) cnt++;
            }
        } System.out.println(cnt);
    }
}

 

 

 

🌀 성능

  • 메모리 : 26,548 KB
  • 실행시간 : 312 ms

 

 

 


토르 불쌍해 ㅠ