QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#188654 | #1093. Bookcase Solidity United | ZSH_ZSH | WA | 3ms | 13092kb | C++14 | 1.4kb | 2023-09-26 10:13:29 | 2023-09-26 10:13:30 |
Judging History
answer
#include<bits/stdc++.h>
#define rep(i,a,b) for (register int i=(a);i<=(b);i++)
#define drep(i,a,b) for (register int i=(a);i>=(b);i--)
typedef long long ll;
using namespace std;
template<typename T1,typename T2> inline void chkmin(T1 &x,const T2 &y){x=(x<y)?x:y;}
template<typename T1,typename T2> inline void chkmax(T1 &x,const T2 &y){x=(x>y)?x:y;}
const int N=75,M=210,lim=200;
int n,a[N],f[N][N][M],g[N][N][M];
void solve()
{
cin>>n;
rep(i,1,n) cin>>a[i];
memset(f,0x3f,sizeof(f));
memset(g,-0x3f,sizeof(g));
rep(i,1,n)
{
rep(j,0,a[i]) f[i][i][j]=a[i]-j,g[i][i][j]=a[i];
rep(j,a[i]+1,lim) f[i][i][j]=0,g[i][i][j]=j;
}
rep(len,2,n) rep(l,1,n-len+1)
{
int r=l+len-1;
rep(v,0,lim)
{
auto upd=[&](int v0,int v1)
{
if (v0<f[l][r][v]) f[l][r][v]=v0,g[l][r][v]=v1;
else if (v0==f[l][r][v]) chkmax(g[l][r][v],v1);
};
int dn=max(v,a[l])/2,coef=max(0,a[l]-v);
upd(coef+f[l+1][r][min(lim,dn)],g[l+1][r][min(lim,dn)]);
rep(k,l+2,r)
{
int dn2=g[l+1][k-1][0]/2;
upd(coef+f[l+1][k-1][0]+f[k][r][min(lim,dn+dn2)],g[k][r][min(lim,dn+dn2)]);
}
}
}
rep(i,1,n) printf("%d ",f[1][i][0]);
printf("\n");
}
int main()
{
ios::sync_with_stdio(false); cin.tie(0);
// freopen("data.in","r",stdin);
// int sid,T; cin>>sid>>T;
int T=1;
while (T--) solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 12848kb
input:
3 8 1 2
output:
8 8 8
result:
ok 3 number(s): "8 8 8"
Test #2:
score: 0
Accepted
time: 3ms
memory: 12860kb
input:
5 10 3 3 8 4
output:
10 10 11 17 17
result:
ok 5 number(s): "10 10 11 17 17"
Test #3:
score: 0
Accepted
time: 3ms
memory: 12864kb
input:
1 1
output:
1
result:
ok 1 number(s): "1"
Test #4:
score: 0
Accepted
time: 0ms
memory: 12816kb
input:
1 150
output:
150
result:
ok 1 number(s): "150"
Test #5:
score: 0
Accepted
time: 0ms
memory: 13092kb
input:
2 80 82
output:
80 122
result:
ok 2 number(s): "80 122"
Test #6:
score: 0
Accepted
time: 3ms
memory: 12792kb
input:
2 4 76
output:
4 78
result:
ok 2 number(s): "4 78"
Test #7:
score: 0
Accepted
time: 0ms
memory: 12860kb
input:
2 32 124
output:
32 140
result:
ok 2 number(s): "32 140"
Test #8:
score: 0
Accepted
time: 0ms
memory: 12808kb
input:
2 2 119
output:
2 120
result:
ok 2 number(s): "2 120"
Test #9:
score: 0
Accepted
time: 0ms
memory: 12808kb
input:
5 4 82 94 39 20
output:
4 84 137 137 137
result:
ok 5 number(s): "4 84 137 137 137"
Test #10:
score: 0
Accepted
time: 0ms
memory: 12852kb
input:
7 85 49 150 12 50 94 113
output:
85 92 218 218 230 274 337
result:
ok 7 numbers
Test #11:
score: 0
Accepted
time: 2ms
memory: 12800kb
input:
8 105 33 66 143 120 43 62 47
output:
105 105 138 246 295 295 327 343
result:
ok 8 numbers
Test #12:
score: 0
Accepted
time: 0ms
memory: 12748kb
input:
9 43 123 72 93 32 65 43 71 81
output:
43 145 156 213 213 248 259 309 355
result:
ok 9 numbers
Test #13:
score: 0
Accepted
time: 3ms
memory: 12804kb
input:
9 20 77 41 80 120 75 75 69 120
output:
20 87 90 150 230 245 283 315 401
result:
ok 9 numbers
Test #14:
score: 0
Accepted
time: 3ms
memory: 12796kb
input:
9 148 134 18 2 12 130 107 12 122
output:
148 208 208 208 208 287 329 329 404
result:
ok 9 numbers
Test #15:
score: 0
Accepted
time: 0ms
memory: 12744kb
input:
9 117 96 145 139 146 36 140 2 12
output:
117 155 252 319 396 396 481 481 481
result:
ok 9 numbers
Test #16:
score: 0
Accepted
time: 0ms
memory: 12884kb
input:
9 49 95 10 14 38 45 22 141 109
output:
49 120 120 120 139 157 157 279 318
result:
ok 9 numbers
Test #17:
score: 0
Accepted
time: 0ms
memory: 12748kb
input:
9 27 57 136 48 126 100 54 131 149
output:
27 71 179 179 261 298 302 406 490
result:
ok 9 numbers
Test #18:
score: 0
Accepted
time: 0ms
memory: 12808kb
input:
9 108 10 9 81 64 110 86 121 47
output:
108 108 108 145 169 247 278 356 356
result:
ok 9 numbers
Test #19:
score: 0
Accepted
time: 0ms
memory: 13036kb
input:
9 86 114 128 106 2 15 119 64 40
output:
86 157 228 270 270 270 345 350 358
result:
ok 9 numbers
Test #20:
score: -100
Wrong Answer
time: 0ms
memory: 12796kb
input:
9 56 76 105 140 90 25 1 54 80
output:
56 104 171 259 279 279 279 307 355
result:
wrong answer 8th numbers differ - expected: '305', found: '307'