-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path684B.cpp
More file actions
48 lines (46 loc) · 959 Bytes
/
684B.cpp
File metadata and controls
48 lines (46 loc) · 959 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <bits/stdc++.h>
using namespace std;
#define intt long long int
int main()
{
intt t;
scanf("%lld", &t);
while (t--)
{
intt n, k;
scanf("%lld %lld", &n, &k);
intt m = n*k;
intt arr[m+1];
for (int i = 1; i <= m ; i++)
{
scanf("%lld", &arr[i]);
}
intt l = (n+1)/2;
intt x = l-1;
l = n-x;
intt p = l;
intt ans = 0;
if(n == 2){
// int ans = 0;
for (int i = 1; i <= m; i+= 2)
{
ans += arr[i];
}
printf("%lld\n",ans);
continue;
}
for (int i = n*k; i > x*k ; i--)
{
if(p > 1){
p--;
}
else
{
p = l;
ans += arr[i];
}
}
printf("%lld\n",ans);
}
return 0;
}