Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Incorrecto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 8 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 1 KBi |
#9 |
Incorrecto
|
0.005 s | 3 KBi |
#10 |
Correcto
|
0.005 s | 2 KBi |
#11 |
Correcto
|
0.007 s | 10 KBi |
#12 |
Correcto
|
0.008 s | 1 KBi |
#13 |
Incorrecto
|
0.006 s | 2 KBi |
#14 |
Tiempo límite excedido
|
1.034 s | 3 KBi |
#15 |
Correcto
|
0.081 s | 3 KBi |
#16 |
Correcto
|
0.09 s | 3 KBi |
#17 |
Correcto
|
0.095 s | 3 KBi |
#18 |
Correcto
|
0.089 s | 3 KBi |
#19 |
Correcto
|
0.088 s | 4 KBi |
#20 |
Tiempo límite excedido
|
1.047 s | 3 KBi |
// https://codeo.app/problemas/0xf2-partir-un-arreglo-en-2 // Calculate index to which right part sum is negative and left side positive (bigger left) #include <iostream> #include <vector> using namespace std; int main() { int n, partitionIndex, leftSum, rightSum; vector<int> arr; // Read inputs cin >> n; arr = vector<int>(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } partitionIndex = -1; rightSum = 0; // Navigate from right to left, checking left when right part sum is neg for (int i = n - 1; i > 0; i--) { rightSum += arr[i]; if (rightSum < 0) { leftSum = 0; for (int j = i - 1; j > 0; j--) { leftSum += arr[j]; } if (leftSum >= 0) { partitionIndex = i; } } } // Output if (partitionIndex == -1) { cout << "Impossible" << endl; } else { cout << partitionIndex << endl; } return 0; }