社区讨论
0分求助
P10721[GESP202406 六级] 计算得分参与者 2已保存回复 1
讨论操作
快速查看讨论及其快照的属性,并进行相关操作。
- 当前回复
- 1 条
- 当前快照
- 1 份
- 快照标识符
- @m2fkc0s7
- 此快照首次捕获于
- 2024/10/19 10:52 去年
- 此快照最后确认于
- 2025/11/04 16:52 4 个月前
CPP
#include <bits/stdc++.h>
#define int long long
#define LIMIT 114514
using namespace std;
const int N=2e5+5;
int n,m,res,ans;
int a[25],f[N];
string st;
signed main(){
cin.tie(0)->sync_with_stdio(0);
cin>>n;
for(int i=1; i<=n; i++){
cin>>a[i];
for(int j=i; j<=LIMIT; j++)
f[j]=max(f[j],f[j-i]+a[i]);
}
cin>>m>>st;
st="#"+st;
for(int i=1; i<=m; i++){
if(st[i]=='a'&&st[i+1]=='b'&&st[i+2]=='c'){
i+=2;
res++;
}
else{
ans+=f[res];
res=0;
}
}
cout<<ans<<"\n";
return 0;
}
回复
共 1 条回复,欢迎继续交流。
正在加载回复...