1 solutions
-
1
#include <iostream> using namespace std; typedef long long LL; const int N = 100010; LL s[N]; LL n, k; LL res; int main() { cin >> n >> k; for(int i = 1; i <= n; ++ i) { cin >> s[i]; s[i] += s[i - 1]; } for(int i = k; i <= n; ++ i) { res = max(res, s[i] - s[i - k]);//所有长度为k的区间 } cout << res << '\n'; return 0; }
- 1
Information
- ID
- 5515
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 8
- Tags
- # Submissions
- 34
- Accepted
- 5
- Uploaded By