https://www.acmicpc.net/problem/25214
25214번: 크림 파스타
각 \(A_i\)가 추가된 직후의 문제의 답 \(N\)개를 공백으로 구분하여 출력한다.
www.acmicpc.net
package BOJ.dp;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.function.Function;
public class BOJ_25214 {
private static final int INF = 1_000_000_009;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
Function<String,Integer> stoi = Integer::parseInt;
int n = stoi.apply(st.nextToken());
int[] input = new int[n];
int min = INF;
int result = 0;
st = new StringTokenizer(br.readLine());
for(int i = 0 ; i < n ; i++){
input[i] = stoi.apply(st.nextToken());
min = Math.min(min,input[i]);
result = Math.max(result,input[i] - min);
System.out.print(result + " ");
}
}
}
'알고리즘' 카테고리의 다른 글
백준 26215번 눈 치우기 (JAVA) (0) | 2023.02.08 |
---|---|
백준 8911번 거북이 (JAVA) (0) | 2023.02.07 |
백준 15645번 내려가기2(JAVA) (0) | 2023.02.05 |
백준 15992번 1,2,3 더하기 7 (JAVA) (0) | 2023.02.04 |
백준 1331번 나이트 투어 (JAVA) (0) | 2023.02.03 |