二分答案,注意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],…
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…