Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 2 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.005 s | 18 KBi |
#4 |
Correcto
|
0.005 s | 2 KBi |
#5 |
Correcto
|
0.004 s | 2 KBi |
#6 |
Correcto
|
0.007 s | 2 KBi |
#7 |
Correcto
|
0.004 s | 2 KBi |
#8 |
Correcto
|
0.006 s | 7 KBi |
#9 |
Correcto
|
0.006 s | 40 KBi |
#10 |
Correcto
|
0.005 s | 2 KBi |
#11 |
Correcto
|
0.005 s | 19 KBi |
#12 |
Correcto
|
0.005 s | 1 KBi |
#13 |
Correcto
|
0.005 s | 2 KBi |
#14 |
Correcto
|
0.159 s | 4 KBi |
#15 |
Correcto
|
0.153 s | 3 KBi |
#16 |
Correcto
|
0.173 s | 11 KBi |
#17 |
Correcto
|
0.171 s | 10 KBi |
#18 |
Correcto
|
0.169 s | 7 KBi |
#19 |
Correcto
|
0.128 s | 4 KBi |
#20 |
Correcto
|
0.172 s | 4 KBi |
#include<bits/stdc++.h> using namespace std; #define optimizar_io ios_base::sync_with_stdio(0); cin.tie(0); #define fore(i, a, b) for(int i = a; i < b; i++) #define fori(i, a, b) for(int i = a; i <= b; i++) #define all(a) a.begin(),a.end() #define pb push_back #define popb pop_back #define mk make_pair #define fi first #define se second #define endl '\n' #define MAX 200 typedef long long int lli; typedef long double ld; int main() { int cases, n; cin >> cases; vector <int> numbers; int left = 0, right = 0; while (cases--){ cin >> n; numbers.push_back(n); right += n; } int n_min = numbers.size() + 5; int index = numbers.size(); for(int i=0;i<numbers.size();i++){ left += numbers[i]; right -= numbers[i]; if(left > 0 && right < 0){ index = (i+1); n_min = min(n_min, index); } } if(n_min != numbers.size() + 5) cout << n_min << endl; else cout << "Impossible" << endl; return 0; }