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

[코드]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AXO8QBw6Qu4DFAXS
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 n = Integer.parseInt(br.readLine());
int[] a = new int[n];
int[] b = new int[n];
for(int i=0;i<n;i++) {
st = new StringTokenizer(br.readLine());
a[i] = Integer.parseInt(st.nextToken());
b[i] = Integer.parseInt(st.nextToken());
}
int result = 0;
for(int i=0;i<n-1;i++) {
for(int j=i+1;j<n;j++) {
if(a[i]>a[j] && b[i]<b[j] || a[i]<a[j] && b[i]>b[j]) result++;
}
}
System.out.println("#"+tc+" "+result);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 숫자가 같은 배수 (0) | 2025.11.13 |
|---|---|
| [SWEA] 상원이의 연속 합 (0) | 2025.11.12 |
| [SWEA] 1차원 정원 (0) | 2025.11.12 |
| [SWEA] 한빈이와 Spot Mart (0) | 2025.11.12 |
| [SWEA] 퍼펙트 셔플 (0) | 2025.11.12 |