#include #include using namespace std; using namespace atcoder; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair; using pdd = pair; using pll = pair; using pli = pair; using pil = pair; template using Graph = vector>; const int MOD = 1e9 + 7; const ld PI = acos(-1); int main() { cin.tie(0); ios::sync_with_stdio(false); int N, M; cin >> N >> M; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } vector> dp(N + M + 1, vector(N + 1, -1e18)); vector> rec(N + M + 1, vector(N + 1, false)); dp[0][0] = 0; for (int i = 0; i < N + M; ++i) { for (int j = 0; j <= N; ++j) { if (dp[i + 1][j] < dp[i][j]) { dp[i + 1][j] = dp[i][j]; rec[i + 1][j] = false; } if (j < N) { ll tmp = dp[i][j] + ((i - j) & 1 ? -A[j] : A[j]); if (dp[i + 1][j + 1] < tmp) { dp[i + 1][j + 1] = tmp; rec[i + 1][j + 1] = true; } } } } vector ans; int now = N; for (int i = N + M; i >= 1; --i) { if (!rec[i][now]) { ans.emplace_back(now); } now -= rec[i][now]; } reverse(ans.begin(), ans.end()); for (auto i : ans) { cout << i << "\n"; } return 0; }