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


[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWkIlHWqBYcDFAXC
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++) {
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int m = Integer.parseInt(st.nextToken());
int[] cnt = new int[n+m+1];
int max = 0;
for(int i=1;i<=n;i++) {
for(int j=1;j<=m;j++) {
int sum = i+j;
cnt[sum]++;
max = Math.max(max, cnt[sum]);
}
}
PriorityQueue<Integer> pq = new PriorityQueue<>();
for(int i=2;i<=n+m;i++) {
if(cnt[i]==max) {
pq.offer(i);
}
}
System.out.print("#"+tc+" ");
while(!pq.isEmpty()) {
System.out.print(pq.poll()+" ");
}
System.out.println();
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 장애물 경주 난이도 (0) | 2025.11.17 |
|---|---|
| [SWEA] 문제 제목 붙이기 (0) | 2025.11.17 |
| [SWEA] 모음이 보이지 않는 사람 (0) | 2025.11.17 |
| [SWEA] 의석이의 세로로 말해요 (0) | 2025.11.17 |
| [SWEA] 제곱 팰린드롬 수 (0) | 2025.11.16 |