| Task: | Maximum sum |
| Sender: | klaava |
| Submission time: | 2025-09-15 17:03:04 +0300 |
| Language: | C++ (C++17) |
| Status: | COMPILE ERROR |
Compiler report
input/code.cpp: In function 'int main()':
input/code.cpp:20:20: error: conversion from 'int' to non-scalar type 'std::array<int, 1>' requested
20 | array[n] = 0;
| ^Code
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
void print_v(vector<T> &v) { cout << "{"; for (auto x : v) cout << x << ","; cout << "\b}"; }
int main()
{
int n;
cin >> n;
long long arr[n];
for (int i = 0; i < n; i++)
{
array[n] = 0;
cin >> arr[i];
}
long long best = 0;
long long sum = 0;
for (int i = 0; i < n; i++) {
sum = max(arr[i], sum + arr[i]);
best = max(best, sum);
}
cout << best << "\n";
}
