HDU 2795 Billboard——特殊查询的线段树
来源:互联网 发布:网络教育规范收费标准 编辑:程序博客网 时间:2024/06/06 13:56
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;const int maxn = 1e5 * 2 + 10;int h, w, n, date[maxn], segTree[maxn<<2];void pushup(int root) { segTree[root] = max(segTree[root<<1], segTree[root<<1|1]);}void build(int L, int R, int root) { if (L == R) { segTree[root] = w; return; } int mid = (L + R)>>1; build(L, mid, root<<1); build(mid + 1, R, root<<1|1); pushup(root);}int query(int L, int R, int root, int val) { if (L == R) { segTree[root] -= val; return L; } int mid = (L + R)>>1; int ans = (segTree[root<<1] >= val) ? query(L, mid, root<<1, val) : query(mid + 1, R, root<<1|1, val); pushup(root); return ans;}int main(){ while (scanf("%d %d %d", &h, &w, &n) == 3) { if (h > n) { h = n; } build(1, h, 1); for (int i = 1; i <= n; i++) { int temp; scanf("%d", &temp); if (segTree[1] < temp) { printf("-1\n"); } else { printf("%d\n", query(1, h, 1, temp)); } } } return 0;}
阅读全文
0 0
- HDU 2795 Billboard——特殊查询的线段树
- 线段树 单点更新查询 区间最大值 hdu 2795 Billboard
- HDU 2795 Billboard(线段树,单点查询)
- HDU 2795 Billboard (线段树,单点查询)
- HDU 2795 Billboard (线段树:区间查询最大值)
- HDU 2795——Billboard(线段树)
- HDU 2795 Billboard线段树
- HDU 2795 Billboard 线段树
- Billboard HDU 2795 线段树
- HDU 2795 Billboard 线段树
- hdu 2795 Billboard(线段树)
- HDU 2795 billboard 线段树
- HDU 2795 Billboard(线段树)
- HDU 2795 Billboard 线段树
- hdu 2795 Billboard 线段树
- hdu 2795(线段树)Billboard
- HDU 2795 Billboard(线段树)
- HDU--2795--Billboard--线段树
- java验证码--应用验证码jar包
- 成为Java顶尖程序员 ,看这11本书就够了
- 经典makefile例子(makefile学习)
- CentOS的单用户模式
- python实现的json数据以HTTP GET,POST,PUT,DELETE方式页面请求
- HDU 2795 Billboard——特殊查询的线段树
- Python初步了解(五)
- 神spfa [Noi2014]魔法森林
- RecycleView上拉刷新下拉加载
- 1、Redis简介与安装
- mac地址
- caffe 训练自己的数据 2
- linux中的挂载命令
- Tensorflow学习笔记(一)Win7+python3.5+Tensorflow+pycharm