摘要: /*还是老老实实的先用线段树来解决吧区间和,区间更新对于区间更新,这个如果更新到底的话,比较耗时,所以我新增了递增量。这样如果区间刚好和更新区域一样的话,就不要往下去了。只保存递增量但是区间和的时候,就要有点变换了。出了拿出区间的和(已保存),还要计算从父节点过来的递增量。这个递增量和孩子节点的递增量是可以相加的这样,区间和的复杂度没有增加,区间更新的复杂度小了点。这样的时间大概是 1500ms*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include < 阅读全文
posted @ 2011-04-14 21:11 AC2012 阅读(231) 评论(0) 推荐(0) 编辑
摘要: /*树状数组,二分找第K个*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream>#include <fstream>#include <iomanip>#include <bitset>#include < 阅读全文
posted @ 2011-04-14 16:14 AC2012 阅读(230) 评论(0) 推荐(0) 编辑
摘要: /*换一种更高效的方法。之前的方法之所以超时,是因为找第K大数的方法很慢。查找第K大,可以利用树状数组和二分的方法,二分答案,然后树状数组高效回答这个答案是否靠谱 很多细节需要注意,WA,TLE N多*/// include file#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <cctype>#include <ctime>#include <iostream>#include <sstream 阅读全文
posted @ 2011-04-14 13:52 AC2012 阅读(175) 评论(0) 推荐(0) 编辑