QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#245353 | #5146. Skills | yllcm | WA | 265ms | 22628kb | C++14 | 2.2kb | 2023-11-09 20:57:25 | 2023-11-09 20:57:25 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define db double
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
#define int long long
using namespace std;
inline int read() {
int x = 0; bool op = false;
char c = getchar();
while(!isdigit(c))op |= (c == '-'), c = getchar();
while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
return op ? -x : x;
}
bool chkmax(int &a, int b) {return (b > a ? a = b, true : false);}
const int N = 1e3 + 10;
const int INF = 1e18;
int n;
int a[N][3], f[2][3][N][N];
int calc(int x) {return (x + 1) * x / 2;}
void solve() {
n = read();
for(int i = 1; i <= n; i++) {
for(int j = 0; j < 3; j++) {
a[i][j] = read();
}
}
for(int i = 0; i < 2; i++) {
for(int j = 0; j < 3; j++) {
for(int x = 0; x < 3; x++) {
for(int y = 0; y < 3; y++) {
f[i][j][x][y] = -INF;
}
}
}
}
f[0][0][0][0] = 0;
for(int i = 1; i <= n; i++) {
// printf("now:%d\n", i);
for(int j = 0; j < 3; j++) {
for(int x = 0; x <= i; x++) {
for(int y = 0; y <= i; y++) {
f[1][j][x][y] = f[0][j][x][y];
f[0][j][x][y] = -INF;
}
}
}
for(int j = 0; j < 3; j++) {
for(int x = 0; x <= i; x++) {
for(int y = 0; y <= i; y++) {
chkmax(f[0][j][x][y], f[1][j][x][y]);
int c[3] = {x, y, i - 1};
rotate(c, c + 3 - (j + 1), c + 3);
for(int k = 0; k < 3; k++) {
int d[3] = {c[0], c[1], c[2]};
int val = a[i][k] - (!d[k] ? 0 : calc(x - d[k]));
d[k] = i; rotate(d, d + k, d + 3);
chkmax(f[0][k][d[1]][d[2]], f[1][j][x][y] + val);
}
}
}
}
}
int ans = 0;
for(int i = 0; i <= n; i++) {
for(int j = 0; j <= n; j++) {
int val = 0;
if(i)val -= calc(n - i);
if(j)val -= calc(n - j);
chkmax(ans, max({f[0][0][i][j], f[0][1][i][j], f[0][2][i][j]}) + val);
}
}
printf("%lld\n", ans);
return ;
}
signed main() {
int test = read();
while(test--)solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 13832kb
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: -100
Wrong Answer
time: 265ms
memory: 22628kb
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:
1505829
result:
wrong answer 1st numbers differ - expected: '1505431', found: '1505829'