#include <bits/stdc++.h>
// Shabdan Batyrkulov
using namespace std;
#define MAX 1007
#define pb push_back
#define fr first
#define sc second
#define mk make_pair
#define ll long long
#define ld long double
const long long N = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
ll n, k;
vector <ll> a;
ll ans = 0;
int main () {
ios::sync_with_stdio(0);
scanf ("%I64d %I64d", &n, &k);
a = vector <ll> (n); ll t = 0, s = 0;
for (ll i = 0; i < n; i++) {
scanf ("%I64d", &a[i]);
if (a[i] > 0) t += a[i];
}
s = t;
for (ll i = 0; i < k; i++) {
if (a[i] > 0) t -= a[i];
else s += a[i];
}
ans = max(ans, max(s, t));
for (ll i = k, j = 0; i < n; i++, j++) {
if (a[j] > 0) t += a[j];
else s -= a[j];
if (a[i] > 0) t -= a[i];
else s += a[i];
ans = max(ans, max(s, t));
}
printf ("%I64d\n", ans);
}
./Main.cpp: In function ‘int main()’:
./Main.cpp:24:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘long long int*’ [-Wformat=]
scanf ("%I64d %I64d", &n, &k);
^
./Main.cpp:24:37: warning: format ‘%d’ expects argument of type ‘int*’, but argument 3 has type ‘long long int*’ [-Wformat=]
./Main.cpp:27:38: warning: format ‘%d’ expects argument of type ‘int*’, but argument 2 has type ‘__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type* {aka long long int*}’ [-Wformat=]
scanf ("%I64d", &a[i]);
^
./Main.cpp:43:31: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘long long int’ [-Wformat=]
printf ("%I64d\n", ans);
^
./Main.cpp:24:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
scanf ("%I64d %I64d", &n, &k...