bzoj2748
来源:互联网 发布:实体零售业大数据 编辑:程序博客网 时间:2024/05/13 06:51
辣鸡题。。
#include <cstdio>int n,ST,ma;bool dp[60][1010];int a[60];int read_int () {char c = getchar();int re = 0;for(;c > '9' || c < '0';c = getchar());for(;c >= '0' && c <= '9';c = getchar())re = re * 10 + c - '0';return re;}int main () {n = read_int();ST = read_int();ma = read_int();for(int i = 1;i <= n;++i)a[i] = read_int();if(ST + a[1] <= ma && ST + a[1] >= 0)dp[1][ST + a[1]] = 1;if(ST - a[1] <= ma && ST - a[1] >= 0)dp[1][ST - a[1]] = 1;for(int i = 1;i <= n - 1;++i) {for(int j = 0;j <= ma;++j) {if(dp[i][j]) {if(j + a[i + 1] <= ma && j + a[i + 1] >= 0)dp[i + 1][j + a[i + 1]] = 1;if(j - a[i + 1] <= ma && j - a[i + 1] >= 0)dp[i + 1][j - a[i + 1]] = 1;}}}int ans = -1;for(int i = 0;i <= ma;++i)if(dp[n][i])ans = i;printf("%d\n",ans);}
0 0
- bzoj2748
- bzoj2748
- BZOJ2748(DP)
- BZOJ2748 DP
- [BZOJ2748][HAOI2012]音量调节
- [BZOJ2748] [HAOI2012]音量调节
- 【BZOJ2748】音量调节
- bzoj2748 [HAOI2012]音量调节
- 【Bzoj2748】音量调节
- bzoj2748 [HAOI2012]音量调节
- bzoj2748: [HAOI2012]音量调节
- bzoj2748 [HAOI2012]音量调节
- bzoj2748/HAOI2012题解(动态规划)
- 【bzoj2748】 HAOI2012音量调节 背包dp
- bzoj2748 音量调节 背包动规
- [bzoj2748][HAOI2012] 音量调节 背包dp
- BZOJ2748(HAOI2012)[音量调节]--01背包
- bzoj2748 [HAOI2012]音量调节(dp水)
- Spring 实践 -IoC
- PHP网站从wamp下转到mamp下遇到的问题
- ISO/OSI参考模型,7层网络模型总结
- Enumeration cannot be resolved to a variable
- iOS之微信支付(二)——本地生成订单集成详情
- bzoj2748
- day30:Master的注册机制和状态管理解密
- window.showModalDialog弹出对话框刷新问题的总结
- 检验列的值是否相同
- 下载mysql(镜像+官网)
- 关闭刷新主报表
- 前端性能优化--合并压缩js,减少http请求次数
- 主子窗口填报
- bzoj4006 管道连接 斯坦纳森林 子集Dp