QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#368999 | #2432. Go with the Flow | InfinityNS# | AC ✓ | 2356ms | 5116kb | C++14 | 1.0kb | 2024-03-27 19:10:42 | 2024-03-27 19:10:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N=2505;
const int M=85*N;
int sz[N],n;
int dp[2][M];
vector<int> clr[2];
char s[100];
void Clear(int now){
for(int x:clr[now]){
dp[now][x]=0;
}
clr[now].clear();
}
int Try(int len){
int ans=0;
int now=0,pre=1;
for(int i=1,j;i<=n;i=j){
swap(now,pre);
Clear(now);
int tot=sz[i];
for(j=i+1;j<=n && tot+sz[j]+1<=len;j++)tot+=sz[j]+1;
int offs=sz[i];
for(int k=i+1;k<j;k++){
offs++;
dp[now][offs]=max({dp[pre][offs-1],dp[pre][offs],dp[pre][offs+1]})+1;
ans=max(ans,dp[now][offs]);
clr[now].push_back(offs);
offs+=sz[k];
}
}
Clear(now);
Clear(pre);
return ans;
}
int main(){
scanf("%i",&n);
int tot=0,mxsz=0;
for(int i=1;i<=n;i++){
scanf("%s",s+1);
sz[i]=strlen(s+1);
tot+=sz[i];
mxsz=max(mxsz,sz[i]);
}
tot+=n-1;
int ans=-1,best=-1;
for(int i=mxsz;i<=tot;i++){
int now=Try(i);
if(now>ans){
ans=now;
best=i;
}
}
printf("%i %i\n",best,ans);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3896kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3856kb
Test #3:
score: 0
Accepted
time: 0ms
memory: 3856kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3904kb
Test #5:
score: 0
Accepted
time: 1ms
memory: 3944kb
Test #6:
score: 0
Accepted
time: 1ms
memory: 3816kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3900kb
Test #8:
score: 0
Accepted
time: 0ms
memory: 3864kb
Test #9:
score: 0
Accepted
time: 1ms
memory: 3912kb
Test #10:
score: 0
Accepted
time: 1ms
memory: 3940kb
Test #11:
score: 0
Accepted
time: 0ms
memory: 3824kb
Test #12:
score: 0
Accepted
time: 1ms
memory: 3908kb
Test #13:
score: 0
Accepted
time: 28ms
memory: 3956kb
Test #14:
score: 0
Accepted
time: 29ms
memory: 4004kb
Test #15:
score: 0
Accepted
time: 25ms
memory: 3884kb
Test #16:
score: 0
Accepted
time: 406ms
memory: 4184kb
Test #17:
score: 0
Accepted
time: 390ms
memory: 4044kb
Test #18:
score: 0
Accepted
time: 399ms
memory: 4104kb
Test #19:
score: 0
Accepted
time: 74ms
memory: 3996kb
Test #20:
score: 0
Accepted
time: 42ms
memory: 3900kb
Test #21:
score: 0
Accepted
time: 1146ms
memory: 4576kb
Test #22:
score: 0
Accepted
time: 2286ms
memory: 5116kb
Test #23:
score: 0
Accepted
time: 38ms
memory: 3972kb
Test #24:
score: 0
Accepted
time: 49ms
memory: 4020kb
Test #25:
score: 0
Accepted
time: 695ms
memory: 4408kb
Test #26:
score: 0
Accepted
time: 713ms
memory: 4432kb
Test #27:
score: 0
Accepted
time: 733ms
memory: 4400kb
Test #28:
score: 0
Accepted
time: 163ms
memory: 4180kb
Test #29:
score: 0
Accepted
time: 168ms
memory: 4196kb
Test #30:
score: 0
Accepted
time: 171ms
memory: 4008kb
Test #31:
score: 0
Accepted
time: 2120ms
memory: 4888kb
Test #32:
score: 0
Accepted
time: 1140ms
memory: 4548kb
Test #33:
score: 0
Accepted
time: 915ms
memory: 4584kb
Test #34:
score: 0
Accepted
time: 36ms
memory: 3888kb
Test #35:
score: 0
Accepted
time: 1ms
memory: 3856kb
Test #36:
score: 0
Accepted
time: 1111ms
memory: 4568kb
Test #37:
score: 0
Accepted
time: 2173ms
memory: 5044kb
Test #38:
score: 0
Accepted
time: 2133ms
memory: 5016kb
Test #39:
score: 0
Accepted
time: 1775ms
memory: 4760kb
Test #40:
score: 0
Accepted
time: 1857ms
memory: 4920kb
Test #41:
score: 0
Accepted
time: 1905ms
memory: 4756kb
Test #42:
score: 0
Accepted
time: 2158ms
memory: 4892kb
Test #43:
score: 0
Accepted
time: 2207ms
memory: 5108kb
Test #44:
score: 0
Accepted
time: 2137ms
memory: 4940kb
Test #45:
score: 0
Accepted
time: 1777ms
memory: 4792kb
Test #46:
score: 0
Accepted
time: 1716ms
memory: 4860kb
Test #47:
score: 0
Accepted
time: 1758ms
memory: 4732kb
Test #48:
score: 0
Accepted
time: 1699ms
memory: 4784kb
Test #49:
score: 0
Accepted
time: 2113ms
memory: 4952kb
Test #50:
score: 0
Accepted
time: 1911ms
memory: 4936kb
Test #51:
score: 0
Accepted
time: 1791ms
memory: 4800kb
Test #52:
score: 0
Accepted
time: 1805ms
memory: 4836kb
Test #53:
score: 0
Accepted
time: 1502ms
memory: 4724kb
Test #54:
score: 0
Accepted
time: 1ms
memory: 3900kb
Test #55:
score: 0
Accepted
time: 54ms
memory: 4076kb
Test #56:
score: 0
Accepted
time: 5ms
memory: 3964kb
Test #57:
score: 0
Accepted
time: 2309ms
memory: 5116kb
Test #58:
score: 0
Accepted
time: 2356ms
memory: 5072kb
Test #59:
score: 0
Accepted
time: 70ms
memory: 4136kb
Test #60:
score: 0
Accepted
time: 35ms
memory: 3936kb
Test #61:
score: 0
Accepted
time: 1ms
memory: 3736kb
Test #62:
score: 0
Accepted
time: 21ms
memory: 3980kb
Test #63:
score: 0
Accepted
time: 237ms
memory: 4216kb
Test #64:
score: 0
Accepted
time: 82ms
memory: 3968kb
Test #65:
score: 0
Accepted
time: 1623ms
memory: 4612kb
Test #66:
score: 0
Accepted
time: 0ms
memory: 3752kb