Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int t,n,k,a;
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- cin>>t;
- while(t--)
- {
- cin>>n>>k;
- vector<int> v(k);
- for(int i=0;i<n;++i)
- {
- cin>>a;
- v[i%k]=max(v[i%k],a);
- }
- long long s=0;
- for(auto x: v)
- s+=x;
- cout<<s<<'\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment