Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Incorrecto
|
0.008 s | 2 KBi |
#2 |
Incorrecto
|
0.007 s | 1 KBi |
#3 |
Incorrecto
|
0.006 s | 1 KBi |
#4 |
Incorrecto
|
0.007 s | 1 KBi |
#5 |
Incorrecto
|
0.006 s | 1 KBi |
#6 |
Incorrecto
|
0.006 s | 2 KBi |
#7 |
Incorrecto
|
0.006 s | 2 KBi |
#8 |
Incorrecto
|
0.005 s | 1 KBi |
#9 |
Incorrecto
|
0.006 s | 1 KBi |
#10 |
Incorrecto
|
0.007 s | 1 KBi |
#11 |
Incorrecto
|
0.007 s | 1 KBi |
#12 |
Incorrecto
|
0.006 s | 1 KBi |
#13 |
Incorrecto
|
0.006 s | 1 KBi |
#14 |
Incorrecto
|
0.007 s | 2 KBi |
#15 |
Incorrecto
|
0.007 s | 1 KBi |
#16 |
Incorrecto
|
0.008 s | 2 KBi |
#17 |
Incorrecto
|
0.046 s | 2 KBi |
#18 |
Incorrecto
|
0.054 s | 2 KBi |
#19 |
Incorrecto
|
0.051 s | 2 KBi |
#20 |
Incorrecto
|
0.049 s | 2 KBi |
#21 |
Incorrecto
|
0.044 s | 1 KBi |
#22 |
Incorrecto
|
0.048 s | 2 KBi |
#23 |
Incorrecto
|
0.033 s | 1 KBi |
#24 |
Incorrecto
|
0.027 s | 2 KBi |
#include <iostream> #include <climits> using namespace std; #define MAX(X, Y) (X > Y) ? X : Y #define POS(X) (X > 0) ? X : 0 int maxSum = INT_MIN; int N; int kadane(int* row, int len) { int x, sum, maxSum = INT_MIN; for (sum = POS(row[0]), x = 0; x < N; ++x, sum = POS(sum + row[x])) maxSum = MAX(sum, maxSum); return maxSum; } int main() { cout << "Enter the array length: "; cin >> N; int arr[N]; cout << "Enter the array: "; for (int i = 0; i < N; i++) { cin >> arr[i]; } cout << "The Max Sum is: "<<kadane(arr, N) << endl; return 0; }