Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.11 s | 12 KBi |
#2 |
Correcto
|
0.093 s | 12 KBi |
#3 |
Correcto
|
0.099 s | 13 KBi |
#4 |
Correcto
|
0.065 s | 11 KBi |
#5 |
Correcto
|
0.096 s | 11 KBi |
#6 |
Correcto
|
0.067 s | 13 KBi |
#7 |
Correcto
|
0.065 s | 12 KBi |
#8 |
Correcto
|
0.078 s | 16 KBi |
#9 |
Correcto
|
0.066 s | 11 KBi |
#10 |
Correcto
|
0.107 s | 13 KBi |
#11 |
Correcto
|
0.1 s | 12 KBi |
#12 |
Correcto
|
0.105 s | 12 KBi |
#13 |
Correcto
|
0.12 s | 13 KBi |
#14 |
Correcto
|
0.508 s | 71 KBi |
#15 |
Correcto
|
0.503 s | 70 KBi |
#16 |
Correcto
|
0.456 s | 70 KBi |
#17 |
Correcto
|
0.53 s | 72 KBi |
#18 |
Correcto
|
0.515 s | 71 KBi |
#19 |
Correcto
|
0.517 s | 72 KBi |
#20 |
Correcto
|
0.572 s | 75 KBi |
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; public class Main { public static void main(String[] args) throws IOException { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = Integer.parseInt(br.readLine()); String[] numsS = br.readLine().split(" "); int[] nums = new int[n]; int left = 0; int right = 0; for (int i = 0; i < n; i++) { nums[i] = Integer.parseInt(numsS[i]); right += nums[i]; } boolean foundSolution = false; for (int i = 0; i < n && !foundSolution; i++) { left += nums[i]; right -= nums[i]; if (left > 0 && right < 0) { foundSolution = true; bw.write((i + 1) + "\n"); } } if (!foundSolution) { bw.write("Impossible\n"); } br.close(); bw.close(); } }