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

[문제]
https://swexpertacademy.com/main/code/problem/problemDetail.do?contestProbId=AWYygN36Qn8DFAVm
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++) {
StringBuilder sb = new StringBuilder();
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int q = Integer.parseInt(st.nextToken());
int[] box = new int[n+1];
for(int i=1;i<=q;i++) {
st = new StringTokenizer(br.readLine());
int l = Integer.parseInt(st.nextToken());
int r = Integer.parseInt(st.nextToken());
for(int j=l;j<=r;j++) {
box[j] = i;
}
}
for(int i=1;i<=n;i++) {
sb.append(box[i]+" ");
}
System.out.println("#"+tc+" "+sb);
}
}
}'Algorithms > SWEA' 카테고리의 다른 글
| [SWEA] 퍼펙트 셔플 (0) | 2025.11.12 |
|---|---|
| [SWEA] 민석이의 과제 체크하기 (0) | 2025.11.12 |
| [SWEA] 진용이네 주차타워 (0) | 2025.11.12 |
| [SWEA] 원 안의 점 (0) | 2025.11.12 |
| [SWEA] 최장 증가 부분 수열 (0) | 2025.11.12 |