QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#312694 | #5146. Skills | NCl3 | TL | 441ms | 299992kb | C++17 | 2.6kb | 2024-01-24 10:47:40 | 2024-01-24 10:47:41 |
Judging History
answer
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define vi vector<int>
using namespace std;
typedef pair<int, int> pii;
constexpr int N=210;
constexpr int inf = 1e18;
struct A
{
int a;
bool operator<(const A &t) const
{
return a < t.a;
}
};
// priority_queue<pii, vector<pii>, greater<pii>> heap;
// cout << setprecision(n)
void solve()
{
int n;
cin>>n;
// f[n][150][150][150]
vector<array<int,3>> a(n+1);
for(int i=1;i<=n;i++)
for(int j=0;j<3;j++)
cin >> a[i][j];
vector f(3,vector(N,vector(N,vector(N,0ll))));
for(int i=0;i<n;i++){
//0
int nxt=i&1^1,cur=i&1;
for(int j=0;j<N;j++)
for(int k=0;k<N;k++){
int t=0;
int tj = j + (j != 0), tk = k + (k != 0);
if(tj<N&&tk<N){
for (int l = 0; l < N; l++)
t = max(t, f[cur][l][j][k]);
f[nxt][1][tj][tk] = max(f[nxt][1][tj][tk], t+a[i+1][0] - j - k);
}
}
//1
for(int j=0;j<N;j++)
for(int k=0;k<N;k++){
int t=0;
int tj = j + (j != 0), tk = k + (k != 0);
if (tj < N && tk < N)
{
for (int l = 0; l < N; l++)
t = max(t, f[cur][j][l][k]);
f[nxt][tj][1][tk] = max(f[nxt][tj][1][tk], t+a[i+1][1] - j - k);
}
}
//2
for (int j = 0; j < N; j++)
for (int k = 0; k < N; k++)
{
int t = 0;
int tj = j + (j != 0), tk = k + (k != 0);
if (tj < N && tk < N)
{
for (int l = 0; l < N; l++)
t = max(t, f[cur][j][k][l]);
f[nxt][tj][tk][1] = max(f[nxt][tj][tk][1], t+a[i+1][2] - j - k);
}
}
}
int ans=0;
for (int j = 0; j < N; j++)
for (int k = 0; k < N; k++)
ans=max({ans,(f[n&1][1][j][k]),(f[n&1][j][1][k]),(f[n&1][j][k][1])});
// cout<<f[2][0][1][2]<<' '<<f[1][0][1][0]<<' '<<f[1][0][0][1]<<endl;
cout << ans << endl;
}
signed main()
{
// freopen("data3.in", "r", stdin);
// freopen("data3.out", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
cin>>t;
while (t--)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 441ms
memory: 299992kb
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
Time Limit Exceeded
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...