a53

Sume Cuantice

a53
Sep 23rd, 2022
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. int t,n,k,a;
  4.  
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. cout.tie(NULL);
  10. cin>>t;
  11. while(t--)
  12. {
  13. cin>>n>>k;
  14. vector<int> v(k);
  15. for(int i=0;i<n;++i)
  16. {
  17. cin>>a;
  18. v[i%k]=max(v[i%k],a);
  19. }
  20. long long s=0;
  21. for(auto x: v)
  22. s+=x;
  23. cout<<s<<'\n';
  24. }
  25. return 0;
  26. }
  27.  
Advertisement
Add Comment
Please, Sign In to add comment