大水题
这种题谁不能1A谁就吔屎/退役吧(说的就是我)
设dp[i][j]表示调完前i个音量为j有没有可能
没了
// It is made by XZZ
// Fei Fan Ya Xi Lie~~~
#include<cstdio>
#include<algorithm>
using namespace std;
#define il inline
#define rg register
#define vd void
typedef long long ll;
il int gi(){
rg int x=0,f=1;rg char ch=getchar();
while(ch<'0'||ch>'9')f=ch=='-'?-1:f,ch=getchar();
while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
return x*f;
}
bool dp[52][1001];
int c[51];
int main(){
freopen("changingsounds.in","r",stdin);
freopen("changingsounds.out","w",stdout);
int n=gi(),begin=gi(),_max=gi()+1;
for(rg int i=1;i<=n;++i)c[i]=gi();
dp[0][begin]=1;
for(rg int i=1;i<=n;++i)
for(rg int j=0;j<_max;++j){
dp[i][j]=0;
if(j>=c[i])dp[i][j]|=dp[i-1][j-c[i]];
if(j+c[i]<_max)dp[i][j]|=dp[i-1][j+c[i]];
}
int ans=-1;
for(rg int i=0;i<_max;++i)
if(dp[n][i])ans=i;
printf("%d
",ans);
return 0;
}