#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; using ll = long long; using ld = long double; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector A(N); rep(i,N) cin >> A[i]; vector> dp(N + 1, vector(M + 1, -1e18)); vector>> prev(N + 1, vector>(M + 1, {-1, -1})); dp[0][0] = 0; rep(i,N+1)rep(j,M+1) { if(i + 1 <= N) { ll x = (j % 2 == 0 ? +A[i] : -A[i]); if(dp[i + 1][j] < dp[i][j] + x) { dp[i + 1][j] = dp[i][j] + x; prev[i + 1][j] = {i, j}; } } if(j + 1 <= M) { if(dp[i][j + 1] < dp[i][j]) { dp[i][j + 1] = dp[i][j]; prev[i][j + 1] = {i, j}; } } } int n = N, m = M; vector> op = {{n, m}}; while(true) { tie(n, m) = prev[n][m]; if(make_pair(n, m) == make_pair(-1, -1)) break; op.push_back({n, m}); } reverse(op.begin(), op.end()); vector ans; rep(i,int(op.size())-1) { auto [n0, m0] = op[i]; auto [n1, m1] = op[i + 1]; if(m0 < m1) ans.push_back(n0); } for(int a : ans) cout << a << "\n"; }