Skip to content

Instantly share code, notes, and snippets.

@ik11235
Created December 3, 2014 07:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ik11235/0de77000e2c39c04d33d to your computer and use it in GitHub Desktop.
Save ik11235/0de77000e2c39c04d33d to your computer and use it in GitHub Desktop.
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
int t,n,ans=0;
cin>>t>>n;
int m[n+1];
for(int i=0;i<t;i++)
{
cin>>m[i];
ans+=m[i];
}
int now=ans;
for(int i=t;i<n;i++)
{
cin>>m[i];
now=now+m[i]-m[i-t];
ans=max(ans,now);
}
cout<<ans<<endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment