tjut 2795
来源:互联网 发布:面向对象编程步骤 编辑:程序博客网 时间:2024/06/10 03:53
#include<iostream> #include<cstdio> #include<algorithm> using namespace std; #define L l,m,u<<1 #define R m+1,r,u<<1|1 //u*2+1 const int N=200000+10; int h,w,n; int a[N<<2]; void build(int l,int r,int u)//u为根结点 { a[u]=w; if(l==r) return; int m=(l+r)>>1; build(L); build(R); } int query(int x,int l,int r,int u) { if(l==r) { a[u]-=x; return l; } int m=(l+r)>>1; int res=(a[u<<1]>=x)?query(x,L):query(x,R); a[u]=max(a[u<<1],a[u<<1|1]); return res; } int main() { freopen("C:\\Users\\Administrator\\Desktop\\kd.txt","r",stdin); while (~scanf("%d%d%d",&h,&w,&n)) { if(h>n) h=n; build(1,h,1); while(n--) { int x; scanf("%d",&x); if(a[1]<x) printf("-1\n"); else printf("%d\n",query(x,1,h,1)); } } return 0; }
0 0
- tjut 2795
- tjut 2795
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- YII2 隐藏index
- 为什么你要使用java8
- ajax对xml和json语言的解析
- 使用jQuery实现图片自动轮播
- 新一代树莓派 Raspberry Pi 2 性能测试之软件无线电追踪飞机信息
- tjut 2795
- Codeforces 185 A Plant
- phpstorm 与 xdebug
- 调用系统相机
- 轻松搞定面试中的二叉树题目
- 2015-2016 ACM-ICPC, NEERC, Moscow Subregional Contest K
- 35. Search Insert Position
- leetcode Repeated DNA Sequence
- JS setInterval setTimeout的用法