1 solutions
-
0
#include<bits/stdc++.h> using namespace std; using ll=long long; const int N=1e5+9; int a[N]; ll sum=0; int main() { ios::sync_with_stdio(0),cin.tie(0),cout.tie(0); int n;cin>>n; for(int i=1;i<=n;++i)cin>>a[i]; int k,p;//个数,间隔 cin>>k>>p; int cnt=0; ll max_val=-1; int j=1; for(int i=j;i<=n;i+=p) { cnt++; sum+=a[i]; if(cnt==k) { max_val=max(max_val,sum); j++; i=j; cnt=0; sum=0; } } cout<<max_val; return 0; }
Information
- ID
- 4917
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- (None)
- # Submissions
- 4
- Accepted
- 2
- Uploaded By