题解:CF2169E Points Selection
Solution
关键性质:先手最多只会留下
证明很简单,如果留下大于
矩形的周长由两个
考虑状压这四个坐标有没有确定,设
设
代码实现的是前者。
Code
const int N = 3e5 + 5, full = 15;
int n, px[N], py[N], c[N], f[2][20];
void sol() {
cin >> n;
F(i, 1, n) cin >> px[i];
F(i, 1, n) cin >> py[i];
F(i, 1, n) cin >> c[i];
int u = 0;
memset(f[u], -0x3f, sizeof f[u]);
f[0][0] = 0;
F(i, 1, n) {
u ^= 1;
memset(f[u], -0x3f, sizeof f[u]);
F(s, 0, full) {
ckmax(f[u][s], f[u^1][s] + c[i]);
for (int t = s; t; t = (t-1)&s) {
int cur = 0;
if (t & 1) cur += px[i] * 2;
if (t >> 1 & 1) cur -= px[i] * 2;
if (t >> 2 & 1) cur += py[i] * 2;
if (t >> 3 & 1) cur -= py[i] * 2;
ckmax(f[u][s], f[u^1][s^t] + cur);
}
}
}
cout << f[u][full] << '\n';
}