RMQ+二分....枚举 i ,找比 i 小的第一个元素,再找之间的第一个最大元素..... Sticks Problem Time Limit: 6000MS Memory Limit: 65536K Total Submissions: 9338 Accepted: 2443 Description Xuanxuan has n sticks of different length. One day, she puts all her stick…
题意:给你一组数a[n],求满足a[i] < a[k] < a[j] (i <= k <= j)的最大的 j - i . 析:在比赛时,我是暴力做的,虽然错了好多次,后来说理解是rmq,我又用rmq写了一次,发现rmq还没有我暴力快,rwq 2000多,暴力才700. 暴力中加了一个优化条件就是前枚举 i 时,下一个 i 值不一定是i+1,而是满足条件中的最大值的位置.这样优化就是时间很短了. 如果用rmq,就得用两个dp数组分别记录最大值和最小值的下标,然后枚举 i,在i+1 -…
POJ 1681---Painter's Problem(高斯消元) Description There is a square wall which is made of n*n small square bricks. Some bricks are white while some bricks are yellow. Bob is a painter and he wants to paint all the bricks yellow. But there is something…