Problem:
最大の和
問題
n
個の整数からなる数列
a
1
,
a
2
, ...,
a
n
と正整数
k
(1 ≤
k
≤
n
) が与えられる.このとき, 連続して並ぶ
k
個の整数の和
S
i
=
a
i
+
a
i+1
+ ... +
a
i
+
k
-1
(1 ≤
i
≤
n
-
k
+ 1) の最大値を出力するプログラムを作りなさい.
入力
入力は複数のデータセットからなる．各データセットは以下の形式で与えられる．入力は２つのゼロを含む行で終了する．
1 行目には正整数
n
(1 ≤
n
≤  100000) と正整数
k
(1 ≤
k
≤
n
) がこの順に空白で
区切られて書かれている.2 行目以降の第 1 +
i
行目 (1 ≤
i
≤
n
) には, 数列の
i
番目の項
a
i
(-10000 ≤
a
i
≤ 10000) が書かれている.
 採点用データのうち, 配点の 60% 分は
n
≤ 5000,
k
≤ 1000 を満たす.
データセットの数は 5 を超えない．
出力
データセットごとに
S
i
の最大値を１行に出力する．
入出力例
入力例
5 3
2
5
-4
10
3
0 0
出力例
11
上記問題文と自動審判に使われるデータは、
情報オリンピック日本委員会
が作成し公開している問題文と採点用テストデータです。

Submitted solutions:

code_snippet: #include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
int main(){
    while(true){
    int N,K;
    cin >> N >> K;
    if(N == 0 and K == 0) break;
    vector<int> v(N,0);
    for(int i = 0;i < N;i++){
        cin >> v[i];
    }
    vector<int> s(N,0);
    s[0] = v[0];
    for(int i = 1;i < K;i++){
        s[i] = s[i-1] + v[i]; 
    }
    ll m = v[K-1];
    for(int i = K;i < N;i++){
        s[i] = s[i-1] + v[i] - v[i-K];
        if(m < s[i]) m = s[i];
    }
    cout << m << endl;
}
}
accuracy: 1
time_ms: 10
memory_kb: 3768
final_rank: 5

code_snippet: #include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;

typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(v) v.begin(), v.end()

ll llpow(ll a, ll t)
{
  ll res = 1;
  rep(i, t) res *= a;
  return res;
}

ll inf = std::numeric_limits<ll>::max();

// using mint = modint998244353;

vector<ll> dx = {0, 0, 1, -1};
vector<ll> dy = {1, -1, 0, 0};

int main()
{
  vector<ll> anss;
  while (true)
  {
    ll n, k;
    cin >> n >> k;
    if (!n && !k)
    {
      break;
    }
    vector<ll> as(n);
    rep(i, n)
    {
      cin >> as[i];
    }
    vector<ll> sums(n + 1, 0);
    rep(i, n)
    {
      sums[i + 1] = sums[i] + as[i];
    }
    ll ans = 0;
    rep(i, n - k + 1)
    {
      ans = max(sums[i + k] - sums[i], ans);
    }
    anss.push_back(ans);
  }
  for (auto ans : anss)
  {
    cout << ans << endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 4540
final_rank: 18

code_snippet: # include <iostream>
# include <vector>
using namespace std;
const long long INF = 1LL<<60;

int main() {
    // 入力
    int N, K;
    while (cin >> N >> K) {
        if (N == 0) break;
        vector<long long> a(N);
        for (int i = 0; i < N; ++i) cin >> a[i];
        
        vector<int> s(N+1, 0);
        for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i];
        
        long long res = -INF;
        for (int i = 0; i <= N-K; ++i) {
            long long val = s[K+i] - s[i];
            if (res < val) res = val;
        }
        cout << res << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4280
final_rank: 12

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define Rep(i,j,n) for (ll i=(ll)(j);i<=(ll)(n);++i)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const int mod = 998244353;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

/*
ll ti=clock();
cout<<("Execution Time: %.4lf sec", 1.0 * (clock() - ti) / CLOCKS_PER_SEC)<<endl;
*/

int main(){
  while(1){
    ll n,k;
    cin>>n>>k;
    if(n==0){
      return 0;
    }
    vl a(n+1);
    a[0]=0;
    rep(i,n){
      cin>>a[i+1];
      a[i]+=a[i-1];
    }
    ll M=-1;
    Rep(i,k,n){
      chmax(M,a[i]-a[i-k]);
    }
    print(M);
  }
}
accuracy: 1
time_ms: 10
memory_kb: 3652
final_rank: 3

code_snippet: #include <iostream>
#include <vector>

using namespace std;

int main() {
  vector<int> res;
  while (true) {
    int n, k; cin >> n >> k;
    if (n == 0 && k == 0) break;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
      cin >> a[i];
    }

    vector<int> sum(n+1); //sum[i] = i-1までの総和
    sum[0] = a[0];
    for (int i = 1; i < n + 1; ++i) {
      sum[i] = sum[i-1] + a[i-1];
    }

    int maximum = 0;
    for (int i = k; i < n + 1; ++i) {
      maximum = max(maximum, sum[i] - sum[i - k]);
    }
    res.push_back(maximum);
  }
  for (int r: res) cout << r << endl;
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3720
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)

void yes() { cout << "Yes" << endl;}
void no()  {cout << "No" << endl;}

double dis(int x1, int y1, int x2, int y2) {
    return sqrt((x1 - x2)*(x1-x2) + (y1-y2)*(y1-y2));
}


struct Edge {
    int to, w;
};



class UnionFind {
    vector<int> par;
    vector<int> siz;

public:
    UnionFind(int N) {
        par.resize(N);
        siz.resize(N);
        rep(i, N) {
            par[i] = i;
            siz[i] = 1;
        }
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int u, int v) {
        int RootU = root(u);
        int RootV = root(v);
        if (RootU == RootV) return;
        if (siz[RootU] < siz[RootV]) {
            par[RootU] = RootV;
            siz[RootV] += siz[RootU];
        } else {
            par[RootV] = RootU;
            siz[RootU] += siz[RootV];
        }
    }

    bool same(int u, int v) {
        return root(u) == root(v);
    }
};














int main() {
    while(1) {
        int n, k; cin >> n >> k;
        if(n == 0 && k == 0) break;
        vector<ll> a(n), b(n+1);
        rep(i, n) cin >> a[i];
        rep(i, n) b[i+1] = b[i] + a[i];

        ll ans = 0;
        for(int l = 0; l < n; l++) {
            int r = l + k;
            if(r >= n+1) break;
            ans = max(ans, ll(b[r]-b[l]));
        }

        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4520
final_rank: 17

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; // 仮想的な無限大の値
int main()
{
    ll k, N;
    bool flg = 1;
    while (flg)
    {
        cin >> N >> k;
        if (N == 0)
        {
            break;
        }
        vector<ll> a(N, 0);
        vector<ll> acsum(N + 1, 0);

        for (ll i = 0; i < N; i++)
        {
            cin >> a[i];
        }
        // int n1, n2;
        // cin >> n1 >> n2;

        for (ll i = 0; i < N; i++)
        {
            acsum[i + 1] = acsum[i] + a[i];
            // cout << "acsum: " << acsum[i] << endl;
        }

        ll ans = -INF;
        for (ll i = 0; i <= N - k; i++)
        {
            ans = max(acsum[i + k] - acsum[i], ans);
        }
        cout << ans << endl;
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4592
final_rank: 20

code_snippet: #include <iostream>
#include <string>
#include <set>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

int main()
{
    while (true) {
        int n, k;
        cin >> n >> k;
        if (n == 0 && k == 0) break;
        vector<int>li(n);
        for (int i = 0; i < n; i++) {
            cin >> li[i];
        }
        long long m = -10000 * n;
        long long x = 0;
        for (int i = 0; i < n - k + 1; i++) {

            if (i == 0) {
                for (int j = 0; j < k; j++) {
                    x += li[j];
                }

            }
            else {
                x += (li[i + k - 1] - li[i - 1]);

            }
            if (x > m) {
                m = x;
            }

        }
        cout << m << endl;
    }
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3488
final_rank: 2

code_snippet: // competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/0516
#include <iostream>
#include <limits>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <numeric>
/// @brief 累積和
template <class T = std::int64_t>
struct prefix_sum {
    prefix_sum(int _n) : n(_n), data(_n + 1) {}
    template <class U>
    prefix_sum(const std::vector<U> &v) : n(v.size()), data(v.size() + 1) {
        std::inclusive_scan(v.rbegin(), v.rend(), data.rbegin() + 1);
    }
    void build() {
        for (int i = n - 1; i >= 0; --i) data[i] += data[i + 1];
    }
    T get(int k) const {
        assert(0 <= k && k < n);
        return data[k] - data[k + 1];
    }
    void set(int k, int x) { data[k] = x; }
    void add(int k, int x) { data[k] += x; }
    T sum(int r) const {
        assert(0 <= r && r <= n);
        return data[0] - data[r];
    }
    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return data[l] - data[r];
    }
    int min_left(T x) const { return min_left(0, x); }
    int min_left(int l, T x) const {
        assert(0 <= l && l <= n);
        int left = l, right = n + 1;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            (data[l] - data[mid] >= x ? right : left) = mid;
        }
        return right;
    }
    int max_right(T x) const { return max_right(n, x); }
    int max_right(int r, T x) const {
        assert(0 <= r && r <= n);
        int left = -1, right = r;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            (data[mid] - data[r] >= x ? left : right) = mid;
        }
        return left;
    }
  private:
    int n;
    std::vector<T> data;
};
int main(void) {
    while (true) {
        int n, k;
        std::cin >> n >> k;
        if (!n)
            break;
        std::vector<int> a(n);
        for (auto &e : a) std::cin >> e;
        prefix_sum<int> ps(a);
        int ans = std::numeric_limits<int>::lowest();
        for (int i = 0; i < n - k + 1; ++i) ans = std::max(ans, ps.sum(i, i + k));
        std::cout << ans << '\n';
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4096
final_rank: 8

code_snippet: // competitive-verifier: PROBLEM https://onlinejudge.u-aizu.ac.jp/problems/0516
#include <iostream>
#include <limits>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <numeric>
/// @brief 累積和
template <class T = std::int64_t>
struct prefix_sum {
    prefix_sum(int _n) : n(_n), data(_n + 1) {}
    template <class U>
    prefix_sum(const std::vector<U> &v) : n(v.size()), data(v.size() + 1) {
        std::partial_sum(v.rbegin(), v.rend(), data.rbegin() + 1);
    }
    void build() {
        for (int i = n - 1; i >= 0; --i) data[i] += data[i + 1];
    }
    T get(int k) const {
        assert(0 <= k && k < n);
        return data[k] - data[k + 1];
    }
    void set(int k, int x) { data[k] = x; }
    void add(int k, int x) { data[k] += x; }
    T sum(int r) const {
        assert(0 <= r && r <= n);
        return data[0] - data[r];
    }
    T sum(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        return data[l] - data[r];
    }
    int min_left(T x) const { return min_left(0, x); }
    int min_left(int l, T x) const {
        assert(0 <= l && l <= n);
        int left = l, right = n + 1;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            (data[l] - data[mid] >= x ? right : left) = mid;
        }
        return right;
    }
    int max_right(T x) const { return max_right(n, x); }
    int max_right(int r, T x) const {
        assert(0 <= r && r <= n);
        int left = -1, right = r;
        while (right - left > 1) {
            int mid = (left + right) / 2;
            (data[mid] - data[r] >= x ? left : right) = mid;
        }
        return left;
    }
  private:
    int n;
    std::vector<T> data;
};
int main(void) {
    while (true) {
        int n, k;
        std::cin >> n >> k;
        if (!n)
            break;
        std::vector<int> a(n);
        for (auto &e : a) std::cin >> e;
        prefix_sum<int> ps(a);
        int ans = std::numeric_limits<int>::lowest();
        for (int i = 0; i < n - k + 1; ++i) ans = std::max(ans, ps.sum(i, i + k));
        std::cout << ans << '\n';
    }
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4096
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
const double pi = acos(-1);
const vector<int> dr= {-1, -1, -1, 0, 0, 1, 1, 1};
const vector<int> dc = {-1, 0, 1, -1, 1, -1, 0, 1};
const long long INF = 1LL<<60; // 仮想的な無限大の値


int main() {
	int n,k;
	while(cin >> n >> k){
		if(n==0) break;
		vector<ll> a(n),b(n+1,0);
		rep(i,n) cin >> a[i];
	
		ll ans = -INF;
	
		rep(i,n){
			b[i+1]= b[i] + a[i];
		}
	
		rep(i,n-k+1){
			ans = max(ans,b[i+k]-b[i]);
		}
	
		cout << ans << endl;
	}
	
}
accuracy: 1
time_ms: 10
memory_kb: 4556
final_rank: 19

code_snippet: #ifdef _DEBUG
#include <ownenv.h>
#define _GLIBCXX_DEBUG
#define debug(var) DEBUG(#var, var)
#else
#define debug(var)
#include <bits/stdc++.h>
#endif

using namespace std;

using ll = long long; using ull = unsigned ll;
using ld = long double;
using uc = unsigned char;
#define INF 2e61

template<typename T> using ve = vector<T>; template<typename T> using vv = ve<ve<T>>;
using vi = ve<int>; using vvi = vv<int>;
using vl = ve<ll>; using vvl = vv<ll>;
using vs = ve<string>; using vvs = vv<string>;
using vc = ve<char>; using vvc = vv<char>;
using vb = ve<bool>; using vvb = vv<bool>;

template<typename T, typename U> using pa = pair<T, U>;
template<typename T> using pTT = pa<T, T>; template<typename T> using pp = pa<T, pTT<T>>;
using pii = pTT<int>; using ppii = pp<int>;
using pll = pTT<ll>; using ppll = pp<ll>;
using psi = pa<string, int>; using pis = pa<int, string>;
using psu = pa<string, uc>; using pus = pa<uc, string>;

#define nall(n) n.begin(), n.end()
#define rnall(n) n.rbegin(), n.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; i--)
#define rrep2(i, n, e) for (int i = (n); i >= (int)(e); i--)
#define elfor(x, V) for(auto &x : V)
#define bitfor(b, n) rep(b, (1 << n))
#define bitfor2(b, s, n) rep2(b, s, (1 << n))
#define getbitelm(i, b, n) rep(i, n) if(b & (1 << i))
#define cl '\n'
#define cend cout << cl
#define print(s) cout << (s) << cl
#define printarry(i, A) rep(i, A.size()) { if(i) cout << ' '; cout << A.at(i);} cout << endl;
#define print12(c) cout << (c).first << ' ' << (c).second << cl
#define print21(c) cout << (c).second << ' ' << (c).first << cl
#define Yes cout << "Yes" << cl
#define YES cout << "YES" << cl
#define No cout << "No" << cl
#define NO cout << "NO" << cl
#define inistd cin.tie(nullptr); ios_base::sync_with_stdio(0)
#define fixout(n) cout << fixed << setprecision(n)

ll n, k;

void solve() {
    vl A(n);
    elfor(a, A) cin >> a;
    vl S(n+1, 0);
    for(int i = 0; i < n; i++) {
        S[i + 1] = S[i] + A[i];
    }
    ll ans = 0;
    for(int i = 0; i < n + 1 - k; i++) {
        ans = max(ans, S[i+k] - S[i]);
    }
    cout << ans << cl;
}

int main() {
    while(cin >> n >> k) {
        if(n == 0 && k == 0) return 0;
        solve();
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4440
final_rank: 15

code_snippet: #include <bits/stdc++.h>
#include <cmath>
using namespace std;

int main() {
    int n, k;
    cin >> n >> k;
    while(n != 0 || k != 0) {
        vector<int> a(n);
        for(int i = 0; i < n; i++) cin >> a[i];
        vector<int> s(n+1, 0);
        for(int i = 0; i < n; i++) {
            s[i+1] = s[i] + a[i+1];
        }
        int M = s[k] - s[0];
        for(int i = 1; i < n-k; i++) {
            M = max(M, s[i+k] - s[i]);
        }
        cout << M << endl;
        cin >> n >> k;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3836
final_rank: 7

code_snippet: #include <iostream>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <numeric>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

void solve(){
  while(1){
  int n,k;
  cin >> n >> k;
  if(n==0 && k==0) break;
  vector<int> a(n);
  rep(i,n) cin >> a[i];

  vector<long long> b(n+1);
  b[0]=0;
  rep(i,n) b[i+1]=b[i]+a[i];

  long long res=-1e16;
  rep(i,n-k+1){
    res = max(res,b[i+k]-b[i]);
  }
  cout << res << endl;
  }
}

int main(){
  solve();
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4308
final_rank: 13

code_snippet: // #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template <typename T>
inline void print(const vector<T>& v, string s = " ") {
  rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");
}
ll div_ceil(ll a, ll b) { return (a >= 0 ? (a + b - 1) : a) / b; }
vector<int> di = {-1, 0, 0, 1}, dj = {0, -1, 1, 0};

int main() {
  ll N, K;
  while (cin >> N >> K) {
    if (N == 0) break;
    vector<ll> A(N), S(N + 1);
    rep(i, N) cin >> A[i];
    rep(i, N) S[i + 1] = S[i] + A[i];

    ll ans = 0;
    rep(i, N - K + 1) { ans = max(ans, S[i + K] - S[i]); }
    cout << ans << endl;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4512
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,k;
    while(1){
        cin >> n >> k;
        vector<int> A(n);
        if(n==0&&k==0) break;
        for(int i = 0; i < n; i++){
            cin >> A[i];
        }
        vector<int> sum(n+1,0);
        for(int i = 1; i <= n; i++){
            sum[i] = sum[i-1] + A[i-1];
        }
        int ans = -1e9;
        for(int i = 0; i+k-1 < n; i++){
            int right = (i+k-1)+1;
            int left = i;
            ans = max(ans,sum[right]-sum[left]);
        }
        cout << ans << endl;
    }
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4096
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    int n,k;
    while(1){
        cin >> n >> k;
        vector<int> A(n);
        if(n==0&&k==0) break;
        for(int i = 0; i < n; i++){
            cin >> A[i];
        }
        vector<int> sum(n+1,0);
        for(int i = 1; i <= n; i++){
            sum[i] = sum[i-1] + A[i-1];
        }
        int ans = -1e9;
        for(int i = 0; i+k <= n; i++){
            ans = max(ans,sum[k+i]-sum[i]);
        }
        cout << ans << endl;
    }
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 4096
final_rank: 8

code_snippet: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using vvi = vector<vector<int>>;

int main() {

    int n, k;
    while(cin >> n >> k) {
        if (n == 0) break;

        vector<ll> a(n);
        rep(i,n) {
            cin >> a[i];
        }

        vector<int> s(n+1,0);
        rep(i, n+1) {
            s[i+1] = s[i] + a[i];  
        }

        ll ans = -1LL<<60;
        rep(i, n+1-k) {
            ll val = s[i+k] - s[i];
            if (val > ans) {
                ans = val;
            }
        }

        cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 4352
final_rank: 14

code_snippet: #include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
const int inf = 1<<30;
const long long MOD1 = 1000000007;
const long long MOD2 = 998244353;
typedef long long ll;
//a:97, A:65
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
const double PI = acos(-1);
typedef string::const_iterator State;//構文解析用

int main(){
    while(1){
    int n,k; cin >> n >> k;
    if(!n&&!k) break;
    vector<ll> s(n+1);
    for(int i=0;i<n;i++){
        ll a; cin >> a;
        s[i+1]=s[i]+a;
    }
    
    ll ans=-INF;
    for(int i=k;i<=n;i++) ans = max(ans,s[i]-s[i-k]);
    cout << ans << endl;
    }
}
accuracy: 1
time_ms: 10
memory_kb: 3800
final_rank: 6

code_snippet: #define _GLGBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

constexpr int INF = (1 << 30);

int main() {
    while (true) {
        int n, k, answer = -INF;
        cin >> n >> k;

        if (!n && !k) break;

        vector<int> a(n + 1);

        for (int i = 1; i <= n; i++) {
            int temp;
            cin >> temp;

            a.at(i) = a.at(i - 1) + temp;
        }

        for (int j = k; j <= n; j++)
            answer = max(answer, a.at(j) - a.at(j - k));

        cout << answer << '\n';
    }
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3464
final_rank: 1