Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 5 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 1 KBi |
#9 |
Correcto
|
0.006 s | 2 KBi |
#10 |
Correcto
|
0.006 s | 1 KBi |
#11 |
Correcto
|
0.006 s | 1 KBi |
#12 |
Correcto
|
0.006 s | 1 KBi |
#13 |
Correcto
|
0.006 s | 1 KBi |
#14 |
Incorrecto
|
0.018 s | 1 KBi |
#15 |
Incorrecto
|
0.017 s | 2 KBi |
#16 |
Correcto
|
0.014 s | 1 KBi |
#17 |
Incorrecto
|
0.014 s | 2 KBi |
#18 |
Incorrecto
|
0.013 s | 1 KBi |
#19 |
Incorrecto
|
0.013 s | 1 KBi |
#20 |
Incorrecto
|
0.019 s | 2 KBi |
#include <iostream> #include <cstring> #include <cstdio> #include <cmath> #include <queue> #include <set> #include <map> #include <vector> #include <stack> #include <algorithm> using namespace std; int main() { int n; int a[50001]; int l[50001]; int r[50001]; bool ya = false; cin>>n; for(int i = 0; i < n; i++) { cin>>a[i]; if(i==0) l[i] = a[i]; else l[i] = l[i-1] + a[i]; } for(int i = n-1; i >= 0; i--) { if(i==n-1) r[i] = a[n-1]; else r[i] = r[i+1] + a[i]; } /*cout<<endl; for(int i = 0; i < n; i++) { cout<<l[i]<<" --- "<<r[i]<<endl; } */ for(int i = 0; i < n-1; i++) { if(l[i] > 0 && r[i+1] < 0) { cout<<i+1<<endl; ya = true; break; } } if(!ya) cout<<"Impossible"<<endl; }