QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#630061 | #5146. Skills | zeemanz | TL | 1253ms | 10348kb | C++20 | 4.4kb | 2024-10-11 16:16:48 | 2024-10-11 16:16:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using f64 = double;
const int B = 200;
constexpr i64 inf = 1E18;
template <class T> void chmax(T &a, T b) { a = max(a, b); }
void solve() {
int n;
cin >> n;
vector<array<int, 3>> a(n);
for (int i = 0; i < n; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
int m = B;
vector dpx(2, vector(m + 1, vector(m + 1, -inf)));
vector dpy(m + 1, vector(2, vector(m + 1, -inf)));
vector dpz(m + 1, vector(m + 1, vector(2, -inf)));
dpx[0][0][0] = dpy[0][0][0] = dpz[0][0][0] = 0;
for (int i = 0; i < n; i++) {
vector ndpx(2, vector(m + 1, vector(m + 1, -inf)));
vector ndpy(m + 1, vector(2, vector(m + 1, -inf)));
vector ndpz(m + 1, vector(m + 1, vector(2, -inf)));
ndpx[0][0][0] = ndpy[0][0][0] = ndpz[0][0][0] = 0;
for (int x = 0; x < 2; x++) {
for (int y = 0; y <= m; y++) {
for (int z = 0; z <= m; z++) {
int nx = x + (x != 0);
int ny = y + (y != 0);
int nz = z + (z != 0);
if (ny <= m && nz <= m) {
chmax(ndpx[1][ny][nz], dpx[x][y][z] + a[i][0] - y - z);
}
if (nx <= m && nz <= m) {
chmax(ndpy[nx][1][nz], dpx[x][y][z] + a[i][1] - x - z);
}
if (nx <= m && ny <= m) {
chmax(ndpz[nx][ny][1], dpx[x][y][z] + a[i][2] - x - y);
}
}
}
}
for (int x = 0; x <= m; x++) {
for (int y = 0; y < 2; y++) {
for (int z = 0; z <= m; z++) {
int nx = x + (x != 0);
int ny = y + (y != 0);
int nz = z + (z != 0);
if (ny <= m && nz <= m) {
chmax(ndpx[1][ny][nz], dpy[x][y][z] + a[i][0] - y - z);
}
if (nx <= m && nz <= m) {
chmax(ndpy[nx][1][nz], dpy[x][y][z] + a[i][1] - x - z);
}
if (nx <= m && ny <= m) {
chmax(ndpz[nx][ny][1], dpy[x][y][z] + a[i][2] - x - y);
}
}
}
}
for (int x = 0; x <= m; x++) {
for (int y = 0; y <= m; y++) {
for (int z = 0; z < 2; z++) {
int nx = x + (x != 0);
int ny = y + (y != 0);
int nz = z + (z != 0);
if (ny <= m && nz <= m) {
chmax(ndpx[1][ny][nz], dpz[x][y][z] + a[i][0] - y - z);
}
if (nx <= m && nz <= m) {
chmax(ndpy[nx][1][nz], dpz[x][y][z] + a[i][1] - x - z);
}
if (nx <= m && ny <= m) {
chmax(ndpz[nx][ny][1], dpz[x][y][z] + a[i][2] - x - y);
}
}
}
}
for (int x = 0; x < 2; x++) {
for (int y = 0; y < 2; y++) {
for (int z = 0; z < 2; z++) {
i64 res = 0;
chmax(res, ndpx[x][y][z]);
chmax(res, ndpy[x][y][z]);
chmax(res, ndpz[x][y][z]);
chmax(ndpx[x][y][z], res);
chmax(ndpy[x][y][z], res);
chmax(ndpz[x][y][z], res);
}
}
}
dpx = move(ndpx);
dpy = move(ndpy);
dpz = move(ndpz);
}
i64 ans = 0;
for (int x = 0; x <= m; x++) {
for (int y = 0; y <= m; y++) {
for (int z = 0; z <= m; z++) {
if (x < 2) {
chmax(ans, dpx[x][y][z]);
}
if (y < 2) {
chmax(ans, dpy[x][y][z]);
}
if (z < 2) {
chmax(ans, dpz[x][y][z]);
}
}
}
}
cout << ans << "\n";
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(16);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 30ms
memory: 10348kb
input:
2 3 1 1 10 1 10 1 10 1 1 5 1 2 3 6 5 4 7 8 9 12 11 10 13 14 15
output:
26 41
result:
ok 2 number(s): "26 41"
Test #2:
score: 0
Accepted
time: 504ms
memory: 10192kb
input:
1 200 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 6323 6099 757 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 8596 825 7437 6098...
output:
1505431
result:
ok 1 number(s): "1505431"
Test #3:
score: 0
Accepted
time: 505ms
memory: 10212kb
input:
1 200 7577 2771 7429 8435 7489 1440 1929 8819 818 7849 8462 8761 3344 5938 3673 9434 8897 6486 4668 636 8139 4777 3305 4238 4221 3326 639 3879 7469 1590 6370 9514 4307 6243 3301 8122 4967 184 9327 6142 1710 399 6814 9296 6270 5663 3564 5442 8315 1295 869 2635 7975 4837 9613 9439 4012 6660 1861 368 8...
output:
1497632
result:
ok 1 number(s): "1497632"
Test #4:
score: 0
Accepted
time: 749ms
memory: 10172kb
input:
1 300 0 10000 0 0 10000 0 0 10000 0 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 10000 0 0 0 0 10000 1000...
output:
2975228
result:
ok 1 number(s): "2975228"
Test #5:
score: 0
Accepted
time: 1253ms
memory: 10196kb
input:
1 500 10000 0 0 10000 0 0 10000 0 0 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10000 0 0 0 10000 0 10...
output:
4955301
result:
ok 1 number(s): "4955301"
Test #6:
score: 0
Accepted
time: 638ms
memory: 10264kb
input:
20 10 6219 3608 2383 1139 2158 8611 6721 8216 8887 8736 6707 9755 7210 248 167 3849 276 8050 971 5062 1914 8290 1562 6017 8993 7990 3460 0 0 0 10 7652 4740 6117 6560 4206 180 3705 8906 5752 9619 8939 9696 793 6680 1777 384 3606 8772 9258 3906 709 4396 5083 6614 6057 4410 3132 1 0 0 10 6098 4958 7691...
output:
71054 70167 68631 74395 65914 65051 62880 65098 62727 71034 64500 71945 54364 66298 74354 70243 65959 78873 58698 72175
result:
ok 20 numbers
Test #7:
score: -100
Time Limit Exceeded
input:
10 100 6477 7917 2869 3623 818 611 7204 100 8682 4362 969 2510 6908 984 5181 2260 1731 6628 4216 5142 96 2604 5754 1992 2495 6672 7175 2278 7381 2075 1083 8778 9329 7535 4274 7337 8259 7742 6826 2873 2891 7320 2082 1988 6680 3674 1820 6637 2634 2964 5548 9745 2848 1275 2120 8514 4029 4256 692 7567 1...