Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.006 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 1 KBi |
#5 |
Correcto
|
0.006 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 |
Correcto
|
0.007 s | 1 KBi |
#10 |
Correcto
|
0.005 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 |
Correcto
|
0.091 s | 7 KBi |
#15 |
Correcto
|
0.087 s | 7 KBi |
#16 |
Correcto
|
0.089 s | 7 KBi |
#17 |
Correcto
|
0.09 s | 7 KBi |
#18 |
Correcto
|
0.109 s | 7 KBi |
#19 |
Correcto
|
0.089 s | 7 KBi |
#20 |
Correcto
|
0.14 s | 7 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[500001]; int l[500001]; int r[500001]; 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; }