Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.005 s | 7 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.005 s | 1 KBi |
#6 |
Correcto
|
0.006 s | 1 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 19 KBi |
#9 |
Correcto
|
0.005 s | 2 KBi |
#10 |
Correcto
|
0.005 s | 1 KBi |
#11 |
Correcto
|
0.005 s | 1 KBi |
#12 |
Incorrecto
|
0.005 s | 1 KBi |
#13 |
Incorrecto
|
0.005 s | 1 KBi |
#14 |
Incorrecto
|
0.047 s | 8 KBi |
#15 |
Correcto
|
0.039 s | 9 KBi |
#16 |
Correcto
|
0.045 s | 10 KBi |
#17 |
Correcto
|
0.047 s | 11 KBi |
#18 |
Incorrecto
|
0.046 s | 8 KBi |
#19 |
Correcto
|
0.044 s | 9 KBi |
#20 |
Incorrecto
|
0.054 s | 9 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=1; for(int i=1; i<=n; i++){ if(prefix[i]>0){ aux=i; break; } } if(prefix[aux]<0){ 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; }