A. Automat $m$超过$1600$是没用的. 从后往前考虑,设$f[i][j][k]$表示考虑$[i,n]$这些物品,一共花费$j$元钱,买了$k$个物品的最大收益. 时间复杂度$O(n^5)$. #include<cstdio> const int N=45,M=1605; int n,m,lim,A,B,i,j,k,x,y,z,o,a[N],b[N],f[2][M][N],ans; inline void up(int&a,int b){a<b?(a=b):0;}…
A. Survival Route 留坑. B. Dispersed parentheses $f[i][j][k]$表示长度为$i$,未匹配的左括号数为$j$,最多的未匹配左括号数为$k$的方案数.时间复杂度$O(n^3)$. #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; const int P=1000000009; const int N=310; int n,m…
A. Area of Effect 首先最优解中必有一个点在圆的边界上. 若半径就是$R$,则枚举一个点,然后把剩下的事件极角扫描即可,时间复杂度$O(m(n+m)\log(n+m))$. 否则圆必然撞到了两个圆,枚举一个点以及两个圆,二分出最大的半径,然后统计内部点数即可,时间复杂度$O(n^2m(n+m))$. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; type…
A. Drone With a Camera 三分套三分. #include<cstdio> #include<cmath> #include<algorithm> using namespace std; typedef long double ld; const ld K=1e9,inf=1e100,eps=1e-9; const int T=200; struct P{ ld x,y; P(){} P(ld _x,ld _y){x=_x,y=_y;} }O; st…