Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Correcto
|
0.005 s | 2 KBi |
#7 |
Correcto
|
0.005 s | 2 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.005 s | 2 KBi |
#10 |
Correcto
|
0.005 s | 10 KBi |
#11 |
Correcto
|
0.005 s | 4 KBi |
#12 |
Incorrecto
|
0.005 s | 2 KBi |
#13 |
Incorrecto
|
0.005 s | 2 KBi |
#14 |
Incorrecto
|
0.045 s | 11 KBi |
#15 |
Correcto
|
0.04 s | 8 KBi |
#16 |
Correcto
|
0.042 s | 10 KBi |
#17 |
Correcto
|
0.044 s | 12 KBi |
#18 |
Incorrecto
|
0.045 s | 9 KBi |
#19 |
Correcto
|
0.042 s | 13 KBi |
#20 |
Incorrecto
|
0.053 s | 12 KBi |
#include <iostream> using namespace std; #define endl '\n' #define ll long long const int maxi = 500001; ll a[maxi]; ll prefix[maxi]; int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin>>n; for(int i=0;i<n; i++){ cin>>a[i]; } for(int i=n; i>=0; i--){ prefix[i]=(prefix[i+1]+a[i]); } int aux=0; for(int i=0; i<=n; i++){ if(prefix[i]>0){ aux=i; break; } } if(prefix[aux]<0){ cout<<"Impossible"<<endl; return 0; } for(int i=aux;i<=n; i++){ if(prefix[i]<0){ cout<<i<<endl; return 0; } } cout<<"Impossible"<<endl; return 0; }