HDUOJ 2795 Billboard
来源:互联网 发布:java b2b2c商城 编辑:程序博客网 时间:2024/05/17 00:59
#ifdef _DEBUG#pragma warning(disable : 4996)#endif#include <iostream>#include <string>#include <vector>#include <stack>#include <queue>#include <deque>#include <set>#include <map>#include <algorithm>#include <functional>#include <sstream>#include <utility>#include <cstring>#include <cstdio>#include <cstdlib>#include <ctime>#include <cmath>#include <cctype>#define CLEAR(a, b) memset(a, b, sizeof(a))#define CLOSE() ios::sync_with_stdio(false)#define IN() freopen("in.txt", "r", stdin)#define OUT() freopen("out.txt", "w", stdout)#define PF(a) printf("%d\n", a)#define SF(a) scanf("%d", &a)#define SFF(a, b) scanf("%d%d", &a, &b)#define FOR(i, a, b) for(int i = a; i < b; ++i)#define LL long long#define MAXN 200010#define MAXM 100005#define MOD 1000007#define INF 2147483648using namespace std;//-------------------------CHC------------------------------////HDUOJ 2795 Billboard#define Lson cur<<1, l, mid#define Rson cur<<1|1, mid+1, rint res[MAXN << 2];int h, w, n;void PushUp(int cur) {res[cur] = max(res[cur << 1], res[cur << 1 | 1]);}void Build(int cur, int l, int r) {if (l == r) {res[cur] = w;return;}int mid = (l + r) >> 1;Build(Lson);Build(Rson);PushUp(cur);}int Query(int val, int cur, int l, int r) {if (l == r) {res[cur] -= val;return l;}int ret = 0;int mid = (l + r) >> 1;if (res[cur << 1] >= val) ret = Query(val, Lson);else ret = Query(val, Rson);PushUp(cur);return ret;}int main() {while (scanf("%d%d%d", &h, &w, &n) == 3) {h = min(h, n);Build(1, 1, h);while (n--) {int val; SF(val);//printf("res[1] = %d\n", res[1]);if (res[1] < val) printf("-1\n");else PF(Query(val, 1, 1, h));}}return 0;}
阅读全文
0 0
- HDUOJ 2795 Billboard
- HDUOJ 2795 Billboard
- hdu 2795 Billboard
- hdu 2795 Billboard
- hdu 2795 Billboard
- hdu 2795 Billboard
- hdoj 2795 Billboard
- hdu 2795 Billboard
- hdu 2795 Billboard
- HDU 2795 - Billboard
- hdu 2795 Billboard
- HDOJ 2795 - Billboard
- HDU-2795-Billboard
- HDU 2795 Billboard
- hdu 2795 Billboard
- HDU 2795 Billboard
- HDOJ 2795 Billboard
- hdu 2795 Billboard
- Android开发初级00_1如何在GIT上托管自己的代码的知识点
- 1250. 【USACO题库】1.4.2 The Clocks (Standard IO)
- php使用CURL
- 算法——归并排序
- 内部类
- HDUOJ 2795 Billboard
- 【Android API】setContentView流程分析
- 阿里云服务器配置开发环境第二章:Centos7.3安装jdk1.8以及环境配置
- PMP第12章采购管理
- 4.Android硬件访问服务编写HAL代码
- 学习笔记--数据库总结(思维导图)
- 几种常见的排序(二)
- 随机梯度下降原理
- 写一个方法void judge(int a, int b, int c).......