1 solutions
-
0
#include using namespace std; int main(){ long long n,k,a[1000001]={0}; long long s[1000001]={0},s1[1000001]={0},Max=0; cin >> n >> k; if (k>=n-1){ cout << 0; return 0; } cin >> a[0]; s[0]=a[0]; for (int i=1;i<n;i++){ cin >> a[i]; s[i]=s[i-1]+a[i]; } if (k>0){ s1[0]=s[k-1]; for (int i=1;i<n-k;i++){ s1[i]=s[i+k]-s[i]; } } for (int i=0;i<n-k;i++){ Max=max(s1[i],Max); } cout << s[n-1]-Max; return 0; }
一定要开longlong
- 1
Information
- ID
- 4618
- Time
- 500ms
- Memory
- 125MiB
- Difficulty
- 2
- Tags
- # Submissions
- 22
- Accepted
- 1
- Uploaded By