切割N個數成K快每塊取M個最大的數,求最大值
排序标記M*K個最大值,之後每M個輸出一個下标
#include <cstdio>
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 +100;
const int MAX_M = 10010;
typedef long long LL;
#define sci(num) scanf("%d",&num)
int N,M,K;
struct as {
int num,loc;
} a[MAX_N];
bool mark[MAX_N];
bool cmp1(const as& a1,const as& a2) {
if (a1.num != a2.num) return a1.num > a2.num;
return a1.loc < a2.loc;
}
int main() {
ios::sync_with_stdio(false); cin.tie(0);
cin >> N >> M >> K;
for (int i = 0;i < N;i++) {
a[i].loc = i;
cin >> a[i].num;
}
sort(a,a + N,cmp1);
LL sum = 0;
for (int i = 0;i < M * K;i++) {
sum += a[i].num;
mark[a[i].loc] = true;
}
int cnt = 0;
int wch = 1;
cout << sum << endl;
bool flag = true;
for (int i = 0;i < N && wch < K;i++) {
if (mark[i]) cnt++;
if (cnt == M) {
cnt = 0;
wch++;
if (flag) {
cout << i + 1;
flag = false;
} else {
cout << " " << i + 1;
}
}
}
cout << endl;
return 0;
}