Cod sursa(job #2723808)
| Utilizator | Data | 15 martie 2021 17:33:33 | |
|---|---|---|---|
| Problema | Secventa 2 | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream fin("secv2.in");
ofstream fout("secv2.out");
const int NMAX = 50003;
long long sp[NMAX];
int main()
{
int n,k;
fin>>n>>k;
for(int i = 1;i <= n;i++)
{
fin>>sp[i];
sp[i] += sp[i - 1];
}
long long ans = -1e9;
for(int i = 1;i <= n - k;i++)
for(int j = i + 1;j <= n;j++)
if(sp[j] - sp[i - 1] > ans)
ans = sp[j] - sp[i - 1];
fout<<ans;
return 0;
}
