Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.006 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 1 KBi |
#3 |
Correcto
|
0.005 s | 1 KBi |
#4 |
Correcto
|
0.006 s | 2 KBi |
#5 |
Correcto
|
0.005 s | 2 KBi |
#6 |
Correcto
|
0.006 s | 2 KBi |
#7 |
Correcto
|
0.007 s | 2 KBi |
#8 |
Correcto
|
0.006 s | 1 KBi |
#9 |
Correcto
|
0.008 s | 1 KBi |
#10 |
Correcto
|
0.006 s | 2 KBi |
#11 |
Correcto
|
0.007 s | 1 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.007 s | 2 KBi |
#14 |
Correcto
|
0.129 s | 7 KBi |
#15 |
Correcto
|
0.154 s | 7 KBi |
#16 |
Correcto
|
0.147 s | 7 KBi |
#17 |
Correcto
|
0.186 s | 7 KBi |
#18 |
Correcto
|
0.198 s | 7 KBi |
#19 |
Correcto
|
0.153 s | 7 KBi |
#20 |
Correcto
|
0.177 s | 7 KBi |
#include<iostream> #include<vector> using namespace std; int main(){ int n; cin>>n; vector<int> vals(n); for(auto &val: vals){ cin>>val; } vector<int> pref(n); vector<int> suff(n); pref[0] = vals[0]; suff[vals.size()-1] = vals[vals.size()-1]; for(int i=1;i<vals.size();i++){ pref[i] = pref[i-1] +vals[i]; suff[vals.size()-1-i] = suff[vals.size()-i] + vals[vals.size()-1-i]; } for(int i=0;i<pref.size()-1;i++){ if(pref[i]>0 && suff[i+1]<0){ cout<<i+1<<endl; return 0; } } cout<<"Impossible\n"; return 0; }