Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.006 s | 7 KBi |
#4 |
Incorrecto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.006 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 1 KBi |
#9 |
Incorrecto
|
0.006 s | 1 KBi |
#10 |
Correcto
|
0.006 s | 1 KBi |
#11 |
Correcto
|
0.006 s | 1 KBi |
#12 |
Correcto
|
0.006 s | 1 KBi |
#13 |
Incorrecto
|
0.006 s | 1 KBi |
#14 |
Incorrecto
|
0.091 s | 3 KBi |
#15 |
Correcto
|
0.08 s | 3 KBi |
#16 |
Correcto
|
0.095 s | 3 KBi |
#17 |
Correcto
|
0.089 s | 6 KBi |
#18 |
Correcto
|
0.097 s | 3 KBi |
#19 |
Correcto
|
0.101 s | 3 KBi |
#20 |
Incorrecto
|
0.131 s | 3 KBi |
// https://codeo.app/problemas/0xf2-partir-un-arreglo-en-2 #include <iostream> #include <vector> using namespace std; int main() { int n, partitionIndex, sum; vector<int> arr; // Read inputs cin >> n; arr = vector<int>(n); for (int i = 0; i < n; i++) { cin >> arr[i]; } // Calculate index to which array is split and right part sum is negative partitionIndex = n; sum = 0; for (int i = n - 1; i >= 0; i--) { sum += arr[i]; // ignores first element to make partition possible if (sum < 0 && i > 0) { partitionIndex = i; } } // Output if (partitionIndex == n) { cout << "Impossible" << endl; } else { cout << partitionIndex << endl; } return 0; }