-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDay69.java
More file actions
32 lines (32 loc) · 778 Bytes
/
Copy pathDay69.java
File metadata and controls
32 lines (32 loc) · 778 Bytes
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
32
import java.util.*;
public class Day69{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
String strsplit[] = str.split(" ");
for (int i=0;i<strsplit.length-1 ; ) {
if (Integer.parseInt(strsplit[i+1])>Integer.parseInt(strsplit[i])) {
System.out.print(strsplit[i+1]+" ");
i++;
}else{
int k=i+1;
boolean check = true;
while(k<strsplit.length){
if (Integer.parseInt(strsplit[k])>Integer.parseInt(strsplit[i])) {
System.out.print(strsplit[k]+" ");
check = false;
break;
}
k++;
}
if (check) {
System.out.print(-1+" ");
}
i++;
}
if (i==strsplit.length-1) {
System.out.print(-1+" ");
}
}
}
}