📍 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
토르 불쌍해 ㅠ
'Algorithm > Boj' 카테고리의 다른 글
[JAVA | 백준] #15836 Matrix Multiplication Calculator 🧮 (0) | 2024.07.09 |
---|---|
[JAVA | 백준] #1237 정ㅋ벅ㅋ (0) | 2024.07.08 |
[JAVA | 백준] #10163 색종이 🟩🟧🟪 (0) | 2024.07.04 |
[JAVA | 백준] #2869 달팽이는 올라가고 싶다 🐌🆙 (0) | 2024.06.17 |
[JAVA | 백준] #2292 벌집 🐝🏠 (0) | 2024.06.08 |