T1 小 M 的作物 先从简化题目入手,考虑先去掉 \(c\) 的额外收益。然后尝试将所有作物种在 \(B\), 则目前得到了 \(\sum \limits_{i = 1} ^n b_i\) 的收益。 接下来我们将每一个作物 \(i\) 分成两个物品,收益分别为 \(a_i,-b_i\),且规定如果想要选收益为 \(a_i\) 的物品,则一定也要选收
一、题目描述 Description 我们都知道哈希是一个很有趣的数据处理方式,尤其是水题的时候23333。 比如我们可以使用哈希加二分在nlogn的复杂度下解决O(n)的马拉车题目, 再比如我们可以在同样O(n)的复杂度下解决一部分KMP问题, 再比如我们可以在O(nlognlogn)的复杂度下解决O(nlogn)的后缀
常用垃圾题黑题模板 长度,是难度的一部分. 快速排序 #include<bits/stdc++.h> using namespace std; #define maxn 100000 #define read(x) scanf("%d",&x) int n; int a[maxn+5]; int main() { read(n); for(int i=1;i<=n;i++) read(a[i]); sort(a+1,a+n+1); for(i
1 #include<iostream> 2 #include<vector> 3 #include<queue> 4 using namespace std; 5 typedef long long ll; 6 const int N = 150; 7 int in[N],n,r; 8 vector<int>ans; 9 vector<int>edge[N]; 10 priority_queue<int,vector&l
http://acm.hdu.edu.cn/showproblem.php?pid=2063 因为要补某一道cf题特意来学一下。。。 匈牙利算法关键在于在能“反悔”的时候尽量“反悔”进行新的匹配以获得更多的匹配数。具体建议看代码很好看懂~ 1 #define bug(x) cout<<#x<<" is "<<x<<endl 2 #define IO std::ios::syn
#include<stdio.h>#include<math.h>const double eps=1e-8;int n;int cmp(double x){ if(fabs(x)<=eps)return 0; if(x<0)return -1; return 1;}struct Point{ double x,y; Point (){} Point (double _x,double _y) { x=_x;
Cornfields Time Limit: 1000MS Memory Limit: 30000K Total Submissions:8623 Accepted: 4100 Description FJ has decided to grow his own corn hybrid in order to help the cows make the best possible milk. To that end, he's looking to build th
正好练练熟练度。。(刷水题谋财害命QAQ) #include<cstdio>#include<iostream>#define ll long long#define R register ll#define ls (tr<<1)#define rs (tr<<1|1)const int M=100010;using namespace std;inline ll g() { R ret=0; register char ch; while(!isd
In the Dark forest, there is a Fairy kingdom where all the spirits will go together and Celebrate the harvest every year. But there is one thing you may not know that they hate walking so much that they would prefer to stay at home if they need to walk a