Codeforces Gym 101061 F(暴力搜索做法)
来源:互联网 发布:淘宝快递合作价格表 编辑:程序博客网 时间:2024/05/16 07:52
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <cmath>#include <string>using namespace std;int coin[110], Max, n;void dfs( int pos, int d, int s, int mmax ){ int unfairness = abs(d-s); if( mmax >= Max ) return; else { if( pos >= n ) { Max = min( mmax, Max ); return; } if( unfairness > mmax ) mmax = unfairness; } dfs( pos+1, d + coin[pos], s, mmax ); dfs( pos+1, d, s + coin[pos], mmax );}int main(){ int T; scanf("%d", &T); while( T-- ) { scanf("%d", &n); for( int i = 0; i < n; i++ ) scanf("%d", &coin[i]); Max = INT_MAX; dfs( 1, coin[0], 0, 0 ); printf( "%d\n", Max ); } return 0;}
0 0
- Codeforces Gym 101061 F(暴力搜索做法)
- codeforces 731F (暴力)
- Codeforces Gym 101138CStickmen 暴力搜索+组合数
- codeforces gym 101142 F(思维)
- codeforces Gym 101102F
- Codeforces-GYM-100726F
- Codeforces GYM 100803F
- Codeforces 691F. Couple Cover (暴力)
- Codeforces 691F. Couple Cover (暴力)
- 【Codeforces Gym 100187F 】+ 贪心
- codeforces-gym-100187-F【贪心】
- Codeforces gym 101350F 想法
- Codeforces Gym 101142 F. Folding
- Codeforces Gym 101164 F. Letter
- Codeforces Gym 100015H Hidden Code(暴力)
- Codeforces Gym 100589F Count Ways(DP+组合数学)
- cf/Codeforces Gym 100548F Color (容斥原理)
- Codeforces Gym 101173 F. Free Figurines (递归)
- Codeforces 446A DZY Loves Sequences【dp】
- 字符串匹配——简单匹配,KMP,分析讲解
- 在cmd使用mongoDB的指令
- Java安全管理器——SecurityManager
- 搞懂JAVA集合类--集合类框架(一)
- Codeforces Gym 101061 F(暴力搜索做法)
- 文件类型检测
- Object c/swift,java,c/c++在32位和64位各个平台上基本数据类型 所占有的字节数
- [LeetCode]--31. Next Permutation
- POJ2420 费马点问题求解 随机化 模拟退火
- 5 Rookie Mistakes to Avoid with Angular 2
- Intent 的隐式跳转总是崩溃的问题(已解决)
- OpenJudge noi 1253 Dungeon Master(POJ 2251)
- Hadoop HA的理解