rt,这个题目实在太难卡了(对于我的代码):
1.能省的数组就剩下来,比如我的代码开始处理了 [1,i] 块比 j 小的 fi,j 和 [i+1,n] 块比 j 大的 fi,j′ ,仔细想想这两个只要一个就够了。
2.块长调到 2n,可以快比较多。
3.开快读,可以使用下面这一份,或者有更强的也行。
4.给函数前面加上 static inline。
5.函数变量里面能加 const int& 的全部加上。
6.提前存一些需要的反复用的变量。
7.循环展开。
8.调换一些数组的维度。
快读:
char buf[1 << 23],*p1,*p2;
#define getc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf,1,1<<20,stdin),p1 == p2)?0:*p1++)
static inline int read(){int x = 0,w = 1;char c = 0;while(c < '0' || c > '9'){if(c == '-')w = -1;c = getc();}while(c <= '9' && c >= '0'){x = (x << 1) + (x << 3) + (c ^ 48);c = getc();}return x * w;}
static inline void print(register long long x){if(x < 0){x = -x;putchar('-');}if(x > 9)print(x / 10);putchar(x % 10 + 48);}