Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 62 KBi |
#5 |
Correcto
|
0.006 s | 1 KBi |
#6 |
Correcto
|
0.005 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 4 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.006 s | 1 KBi |
#10 |
Correcto
|
0.005 s | 5 KBi |
#11 |
Correcto
|
0.006 s | 6 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.006 s | 2 KBi |
#14 |
Correcto
|
0.095 s | 3 KBi |
#15 |
Tiempo límite excedido
|
1.02 s | 5 KBi |
#16 |
Tiempo límite excedido
|
1.071 s | 3 KBi |
#17 |
Tiempo límite excedido
|
1.019 s | 3 KBi |
#18 |
Correcto
|
0.089 s | 3 KBi |
#19 |
Tiempo límite excedido
|
1.024 s | 3 KBi |
#20 |
Tiempo límite excedido
|
1.041 s | 3 KBi |
#include <iostream> #include <vector> #include <cassert> #include <algorithm> using namespace std; void solve(const vector<int> &a, int n, int sum) { for (int i = 0; i < n; ++i) { int left = 0; for (int j = i - 1; j >= 0; --j) { left += a[j]; } int right = sum - left; if (left > 0 and right < 0) { cout << i << endl; return; } } cout << "Impossible" << endl; } int main() { int n; cin >> n; assert(2 <= n and n <= 500000); vector<int> a(n); int sum = 0; for (int i = 0; i < n; ++i) { cin >> a[i]; sum += a[i]; } solve(a, n, sum); return 0; }