思路:二分之后用dp去check就好啦. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PII pair<int, int> #define PLI pair<LL, int> #define ull unsigned long long using namespace std; ; const in…
HDU 3433 A Task Process Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1368 Accepted Submission(s): 684 Problem Description There are two kinds of tasks, namely A and B. There are N workers…
A Task Process Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1332 Accepted Submission(s): 656 Problem Description There are two kinds of tasks, namely A and B. There are N workers and the…
二分答案,注意l是max(a[i]+a[i+1]),r是sum_a 判断的时候用dp,设f[i]为i与1最少的相同颜色数,g[i]为i与1最多的相同颜色数,转移是f[i]=max(a[i]-(w-a[i-1]-(a[1]-g[i-1])),0),g[i]=min(a[1]-f[i-1],a[i]); #include<iostream> #include<cstdio> using namespace std; const int N=20005; int n,a[N],f[N],…
对于第一问二分然后贪心判断即可 对于第二问,设f[i][j]为已经到j为止砍了i段,转移的话从$$ f[i][j]=\sigema f[k][j-1] (s[j]-s[k-1]<=ans) 这里用权和嘴和优化成nm的即可 #include<iostream> #include<cstdio> using namespace std; const int N=50005,mod=10007; int n,m,a[N],f[N],la[N]; long long sm[N],s[…
题目链接: B. Strip time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Alexandra has a paper strip with n numbers on it. Let's call them ai from left to right. Now Alexandra wants to split it into…