Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.082 s | 10 KBi |
#2 |
Correcto
|
0.085 s | 10 KBi |
#3 |
Correcto
|
0.044 s | 14 KBi |
#4 |
Correcto
|
0.052 s | 14 KBi |
#5 |
Correcto
|
0.109 s | 10 KBi |
#6 |
Correcto
|
0.088 s | 42 KBi |
#7 |
Correcto
|
0.047 s | 14 KBi |
#8 |
Correcto
|
0.046 s | 14 KBi |
#9 |
Correcto
|
0.109 s | 10 KBi |
#10 |
Correcto
|
0.068 s | 15 KBi |
#11 |
Correcto
|
0.205 s | 31 KBi |
#12 |
Correcto
|
0.471 s | 29 KBi |
#13 |
Correcto
|
0.2 s | 30 KBi |
import java.io.*; import java.util.StringTokenizer; import java.util.*; class Main { public static void main(String[] args) throws IOException{ List<Integer> arr = new ArrayList<Integer>(); List<Integer> res = new ArrayList<Integer>(); BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st; st = new StringTokenizer(br.readLine()); st = new StringTokenizer(br.readLine()); while(st.hasMoreTokens()){ arr.add(Integer.parseInt(st.nextToken())); } st = new StringTokenizer(br.readLine()); int clave = 0; int x = 0; int mayor = Integer.MIN_VALUE; int pruebas = Integer.parseInt(st.nextToken()); while(x<pruebas){ st = new StringTokenizer(br.readLine()); int l = Integer.parseInt(st.nextToken()); int r = Integer.parseInt(st.nextToken()); if(l==r){ res.add(l); }else{ for(int i=l;i<=r;i++){ if(arr.get(i)>mayor){ mayor=arr.get(i); clave = i; } } mayor = Integer.MIN_VALUE; res.add(clave); } x++; } for(int i : res){ System.out.println(i); } } }