Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Correcto
|
0.005 s | 3 KBi |
#3 |
Correcto
|
0.006 s | 2 KBi |
#4 |
Incorrecto
|
0.005 s | 1 KBi |
#5 |
Correcto
|
0.006 s | 5 KBi |
#6 |
Correcto
|
0.007 s | 5 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.006 s | 1 KBi |
#9 |
Incorrecto
|
0.005 s | 1 KBi |
#10 |
Correcto
|
0.005 s | 1 KBi |
#11 |
Correcto
|
0.005 s | 1 KBi |
#12 |
Incorrecto
|
0.006 s | 1 KBi |
#13 |
Incorrecto
|
0.005 s | 2 KBi |
#14 |
Incorrecto
|
0.057 s | 9 KBi |
#15 |
Correcto
|
0.044 s | 11 KBi |
#16 |
Correcto
|
0.044 s | 12 KBi |
#17 |
Correcto
|
0.045 s | 9 KBi |
#18 |
Correcto
|
0.045 s | 14 KBi |
#19 |
Correcto
|
0.048 s | 9 KBi |
#20 |
Incorrecto
|
0.053 s | 8 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){ // 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=1;i<=n; i++){ if(prefix[i]<0){ cout<<i-1<<endl; return 0; } } cout<<"Impossible"<<endl; return 0; }