Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Correcto
|
0.005 s | 1 KBi |
#2 |
Correcto
|
0.006 s | 2 KBi |
#3 |
Correcto
|
0.007 s | 2 KBi |
#4 |
Correcto
|
0.007 s | 18 KBi |
#5 |
Correcto
|
0.006 s | 26 KBi |
#6 |
Correcto
|
0.006 s | 2 KBi |
#7 |
Correcto
|
0.005 s | 1 KBi |
#8 |
Correcto
|
0.005 s | 1 KBi |
#9 |
Correcto
|
0.005 s | 1 KBi |
#10 |
Correcto
|
0.006 s | 15 KBi |
#11 |
Correcto
|
0.007 s | 13 KBi |
#12 |
Correcto
|
0.006 s | 1 KBi |
#13 |
Correcto
|
0.007 s | 2 KBi |
#14 |
Correcto
|
0.005 s | 1 KBi |
#15 |
Correcto
|
0.006 s | 16 KBi |
#16 |
Correcto
|
0.006 s | 2 KBi |
#17 |
Correcto
|
0.058 s | 3 KBi |
#18 |
Correcto
|
0.063 s | 3 KBi |
#19 |
Correcto
|
0.065 s | 5 KBi |
#20 |
Correcto
|
0.069 s | 2 KBi |
#21 |
Correcto
|
0.048 s | 11 KBi |
#22 |
Correcto
|
0.049 s | 3 KBi |
#23 |
Correcto
|
0.03 s | 3 KBi |
#24 |
Correcto
|
0.049 s | 3 KBi |
#include <iostream> #include <vector> #include <algorithm> // std::max #include <limits.h> using namespace std; int main() { int n; cin >> n; vector<long> a(n); vector<long> r(n); for(int i=0;i<n;i++){ cin >> a[i] ; } r[0] =a[0]; long max1= a[0]; for(int j=1;j<n;j++){ r[j]=max(a[j],a[j]+r[j-1]); max1 = max(max1, r[j]); } cout << max1 << endl; }