Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 문자열
- 시뮬레이션
- priorityqueue
- 코딩테스트
- math
- oracle
- 문제풀이
- 자바
- 투포인터
- Java
- 러닝일지
- DP
- 건강
- 코테
- dfs
- 알고리즘
- db
- SQL
- 운동기록
- COS PRO
- binary search
- MySQL
- BFS
- 이분탐색
- greedy
- 문제해결
- 백준
- SWEA
- BOJ
- 프로그래머스
Archives
- Today
- Total
슈콩
[SWEA] 평범한 숫자 본문

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXhh-H-KwUcDFARQ
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
[소스 코드]
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st;
int T = Integer.parseInt(br.readLine());
for(int tc=1;tc<=T;tc++) {
int result = 0;
int n = Integer.parseInt(br.readLine());
int[] num = new int[n];
st = new StringTokenizer(br.readLine());
for(int i=0;i<n;i++) {
num[i] = Integer.parseInt(st.nextToken());
}
for(int i=1;i<n-1;i++) {
int max = num[i];
int min = num[i];
min = Math.min(min, Math.min(num[i-1], num[i+1]));
max = Math.max(max, Math.max(num[i-1], num[i+1]));
if(num[i]!=min && num[i]!=max) result++;
}
System.out.println("#"+tc+" "+result);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 일요일 (0) | 2025.11.18 |
|---|---|
| [SWEA] 몬스터 사냥 (0) | 2025.11.18 |
| [SWEA] 색상환 (0) | 2025.11.18 |
| [SWEA] 로봇 언어 (0) | 2025.11.18 |
| [SWEA] 승률 비교하기 (0) | 2025.11.18 |