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