E-5题解

#include <iostream>
#include <stack>
using namespace std;
int main() {
    int T;
    cin >> T;
    while (T--) {
        int n, k;
        cin >> n >> k;
        stack<long long> s;
        int nk = n * k, temp;
        while (nk--)
            cin >> temp, s.push(temp);
        long long tempK = k, sum = 0;
        while (tempK--)
        {
            int tempN = n / 2;
            while (tempN--)
                s.pop();
            sum += s.top(), s.pop();
        }
        cout << sum << endl;
    }
    return 0;
}

 

posted @ 2021-05-05 23:13  potentia1  阅读(56)  评论(0)    收藏  举报