标签:acm
const int MAXN = 210; int ipt[MAXN], ta[MAXN], tb[MAXN]; int main() { // freopen("in.txt", "r", stdin); int n, m; while (~RII(n, m)) { FE(i, 1, n) RI(ipt[i]); int ans = -INF; FE(i, 1, n) FE(j, i, n) { int t1 = 0, t2 = 0; FE(k, i, j) ta[t1++] = ipt[k]; FE(k, 1, i - 1) tb[t2++] = ipt[k]; FE(k, j + 1, n) tb[t2++] = ipt[k]; sort(ta, ta + t1); sort(tb, tb + t2); reverse(tb, tb + t2); int e = min(min(m, t1), t2); REP(k, e) ta[k] = max(ta[k], tb[k]); int sum = 0; REP(k, t1) sum += ta[k]; ans = max(ans, sum); } WI(ans); } return 0; }
Codeforces Round #243 (Div. 2)——Sereja and Swaps
标签:acm
原文地址:http://blog.csdn.net/wty__/article/details/24665103