APIO2010特别行动队(单调队列、斜率优化)
2020-12-13 02:33
标签:c style class blog code a 其实这题一看知道应该是DP,再一看数据范围肯定就是单调队列了。 不过我还不太懂神马单调队列、斜率优化…… 附上天牛的题解:http://www.cnblogs.com/neverforget/archive/2012/04/19/2456483.html APIO2010特别行动队(单调队列、斜率优化),搜素材,soscw.com APIO2010特别行动队(单调队列、斜率优化) 标签:c style class blog code a 原文地址:http://www.cnblogs.com/zyfzyf/p/3773965.html 1 var f,g:array[0..1000050] of int64;
2 s,q:array[0..1000050] of longint;
3 a,b,c,n,i,h,t,x:longint;
4 bestk:double;
5 procedure init;
6 begin
7 readln(n);
8 readln(a,b,c);
9 s[0]:=0;
10 for i:=1 to n do
11 begin
12 read(x);
13 s[i]:=s[i-1]+x;
14 end;
15 end;
16 function k(x,y:longint):double;
17 begin
18 exit(double(g[y]-g[x])/(s[y]-s[x]));
19 end;
20 procedure main;
21 begin
22 f[0]:=0;h:=1;t:=1;q[1]:=0;
23 for i:=1 to n do
24 begin
25 bestk:=double(2*a*s[i]);
26 while (h