Skip to content

Commit 664c78d

Browse files
committed
Title: 가장 왼쪽에 있는 최댓값, Time: 0ms, Memory: 0MB, Status: Wrong Answer - Codetree
1 parent 5cc1deb commit 664c78d

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import java.io.*;
2+
import java.util.*;
3+
4+
public class Main {
5+
public static void main(String[] args) throws Exception {
6+
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
7+
8+
int N = Integer.parseInt(br.readLine());
9+
10+
int[] arr = new int[1001];
11+
12+
StringTokenizer st = new StringTokenizer(br.readLine());
13+
int[] nums = new int[N];
14+
for(int i=0; i<N; i++){
15+
nums[i] = Integer.parseInt(st.nextToken());
16+
}
17+
18+
for(int i=N-1; i>=0; i--){
19+
int idx = nums[i];
20+
arr[idx] = i+1;
21+
}
22+
23+
StringBuilder sb = new StringBuilder();
24+
int right = N;
25+
for(int i=1000; i>=0; i--){
26+
if(arr[i]==0) continue;
27+
if(right>arr[i]){
28+
sb.append(arr[i]).append(" ");
29+
right = arr[i];
30+
}
31+
}
32+
System.out.println(sb);
33+
34+
}
35+
}

0 commit comments

Comments
 (0)