贪心
lll_564
这个作者很懒,什么都没留下…
展开
-
Codeforces661 E1. Weights Division(easy version)(贪心+优先队列)
题目链接思路:先计算每条边被计算的次数,然后贪心地每次减半能减少最多花费的边,直到小于等于S为止。代码:#include<bits/stdc++.h>#define ll long long#define LL long long#define PB push_back#define MP make_pairusing namespace std;const int maxn=2e5+100;const ll inf=1e18+10;ll n,s,val[maxn],le原创 2020-08-06 21:14:38 · 113 阅读 · 0 评论 -
2020牛客暑期多校第六场 K-Bag(贪心写法+滑动窗口枚举写法)
题目链接题意:定义k-bag为若干长度为k的全排列组成的串,问题目给出的串是否可能为一个k-bag的子串。贪心思路设定当前全排列的左右指针,从左向右加点,大致情况分以下几种:1.尾指针遇到可加入的数,直接加入。2.当前段满足全排列,进入下一段匹配。3.尾指针遇到重复的数,此时无法继续向右添加,考虑向左边加数,同时将之前匹配成功的每段全排列向左移动。考虑以下两种情况:3.1.头指针是否能前移?若左边需添加的数与当前段中的数有重复,则说明该数与当前段重复的数必不在同一段中,则让尾指针回退,直到可原创 2020-08-01 01:22:46 · 179 阅读 · 0 评论 -
Codeforces660 D. Captain Flint and Treasure(dfs贪心)
D. Captain Flint and TreasureCaptain Fint is involved in another treasure hunt, but have found only one strange problem. The problem may be connected to the treasure’s location or may not. That’s why captain Flint decided to leave the solving the problem原创 2020-08-01 00:36:48 · 132 阅读 · 0 评论