Caso # | Resultado | Tiempo | Memoria |
---|---|---|---|
#1 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#2 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#3 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#4 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#5 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#6 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#7 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#8 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#9 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#10 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#11 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#12 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#13 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#14 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#15 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#16 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#17 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#18 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#19 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#20 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#21 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#22 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#23 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
||
#24 |
Error de compilación
main.cpp:37:5: error: use of undeclared identifier 'vector' vector<int> a(n); ^ main.cpp:37:15: error: expected '(' for function-style cast or type construction vector<int> a(n); ~~~^ main.cpp:37:17: error: use of undeclared identifier 'a' vector<int> a(n); ^ main.cpp:40:16: error: use of undeclared identifier 'a' cin >> a[i]; ^ main.cpp:43:20: error: use of undeclared identifier 'a' cout << kadane(a, n); ^ 5 errors generated. |
#include <iostream> using namespace std; // Function to find the maximum sum of a contiguous subarray // in a given integer array int kadane(int arr[], int n) { // stores the maximum sum subarray found so far int max_so_far = 0; // stores the maximum sum of subarray ending at the current position int max_ending_here = 0; // traverse the given array for (int i = 0; i < n; i++) { // update the maximum sum of subarray "ending" at index `i` (by adding the // current element to maximum sum ending at previous index `i-1`) max_ending_here = max_ending_here + arr[i]; // if the maximum sum is negative, set it to 0 (which represents // an empty subarray) max_ending_here = max(max_ending_here, 0); // update the result if the current subarray sum is found to be greater max_so_far = max(max_so_far, max_ending_here); } return max_so_far; } int main() { int n; cin >> n; vector<int> a(n); for(int i =0;i<n;++i){ cin >> a[i]; } cout << kadane(a, n); return 0; }