ACWing.165 小猫爬山 DFS剪枝
翰翰和达达饲养了N只小猫,这天,小猫们要去爬山。
经历了千辛万苦,小猫们终于爬上了山顶,但是疲倦的它们再也不想徒步走下山了(呜咕>_ b; } void dfs(int now){ if(car.size() >= ans) return; if(now == n){ ans = min(ans, (int)car.size()); return; } for(int i = 0; i < car.size(); i++){ if(car[i] + cat[now] > n >> w; cat = (int *)malloc(n * sizeof(int)); for(int i = 0; i < n; i++) scanf("%d", &cat[i]); sort(cat, cat + n, cmp); ans = n; dfs(0); cout
关注
打赏
热门博文
- 回坑记之或许是退役赛季?
- [LCT刷题] P1501 [国家集训队]Tree II
- [LCT刷题] P2147 洞穴勘测
- 2022-2023 ICPC Brazil Subregional Programming Contest VP记录
- [线段树套单调栈] 2019-2020 ICPC Asia Hong Kong Regional Contest H.[Hold the Line]
- The 2021 ICPC Asia Nanjing Regional Contest E.Paimon Segment Tree 区间合并线段树/维护矩阵乘法
- CF580E - Kefa and Watch 线段树维护哈希
- HDU5869 Different GCD Subarray Query 离线查询/区间贡献
- 27.CF1004F Sonya and Bitwise OR 区间合并线段树
- 26.CF1000F One Occurrence