HDU 2616 Kill the monster
2011-12-24 18:26
387 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2616
枚举所有情况,STL直接生成排列
View Code
枚举所有情况,STL直接生成排列
View Code
#include <cstdio> #include <algorithm> using namespace std; int main() { int n,m,a[10],b[10],p[10],ans,i; while (scanf("%d%d",&n,&m)!=EOF) { ans=n+1; for (i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]); for (i=1;i<=n;i++) p[i]=i; do{ int t=m; for (i=1;i<=n;i++) { if (t<=b[p[i]]) t-=a[p[i]]*2; else t-=a[p[i]]; if (t<=0) break; } if (i<ans) ans=i; }while (next_permutation(p+1,p+n+1)); if (ans>n) ans=-1; printf("%d\n",ans); } }
相关文章推荐
- hdu 2616 Kill the monster(DFS)
- hdu 2616 Kill the monster(简单回溯搜索)
- hdu_2616 Kill the monster
- hdu 2616 Kill the monster(深搜)
- hdu 2616 Kill the monster (DFS)
- HDU 2616 Kill the monster【全文翻译+详解】(广度优先搜索)
- HDU 2616 Kill the monster(生成排列)
- HDU 2616 Kill the monster
- HDU-2616-Kill the monster
- HDU 2616 Kill the monster (暴力搜索 || 终极暴力全排列)
- hdu 2616 Kill the monster(stl全排列+暴力)
- HDU 2616 Kill the monster(简单DFS)
- HDU 2616 Kill the monster 简单DFS
- hdu 2616 Kill the monster
- hdu 2616【Kill the monster】
- hdu 2616 Kill the monster(暴搜)
- HDU 2616 Kill the monster
- HDU 2616 Kill the monster
- HDU 2616 Kill the monster (暴力搜索 || 终极全阵列暴力)
- HDU 2616 Kill the monster【深搜】