https://www.acmicpc.net/problem/10810
10810번: 공 넣기
도현이는 바구니를 총 N개 가지고 있고, 각각의 바구니에는 1번부터 N번까지 번호가 매겨져 있다. 또, 1번부터 N번까지 번호가 적혀있는 공을 매우 많이 가지고 있다. 가장 처음 바구니에는 공이
www.acmicpc.net
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int M = sc.nextInt();
int[] array = new int[N];
for(int i =0 ; i < M ; i++) {
int start = sc.nextInt();
int end = sc.nextInt();
int ballnum = sc.nextInt();
for (int j = start ; j <= end ; j++) {
array[j-1] = ballnum;
}
}
for(int a : array){
System.out.print(a + " ");
}
}
}
'프로그래밍언어 > 알고리즘' 카테고리의 다른 글
백준 5597 과제 안 내신분..?_JAVA (0) | 2023.05.07 |
---|---|
백준 10813 공 바꾸기_JAVA (0) | 2023.05.07 |
백준 2562 최댓값_JAVA (0) | 2023.05.06 |
백준 10818 최소, 최대_JAVA (0) | 2023.05.05 |
백준 10871 X보다 작은 수 (0) | 2023.05.05 |