hdu 2795 Billboard(线段树)

本文探讨了在公告板上放置不同宽度公告的算法过程,包括如何选择放置位置以充分利用空间,以及当空间不足时如何处理。通过实例分析,展示了算法在实际场景中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Billboard

Time Limit: 20000/8000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4292 Accepted Submission(s): 2003


Problem Description
At the entrance to the university, there is a huge rectangular billboard of size h*w (h is its height and w is its width). The board is the place where all possible announcements are posted: nearest programming competitions, changes in the dining room menu, and other important information.

On September 1, the billboard was empty. One by one, the announcements started being put on the billboard.

Each announcement is a stripe of paper of unit height. More specifically, the i-th announcement is a rectangle of size 1 * wi.

When someone puts a new announcement on the billboard, she would always choose the topmost possible position for the announcement. Among all possible topmost positions she would always choose the leftmost one.

If there is no valid location for a new announcement, it is not put on the billboard (that's why some programming contests have no participants from this university).

Given the sizes of the billboard and the announcements, your task is to find the numbers of rows in which the announcements are placed.

Input
There are multiple cases (no more than 40 cases).

The first line of the input file contains three integer numbers, h, w, and n (1 <= h,w <= 10^9; 1 <= n <= 200,000) - the dimensions of the billboard and the number of announcements.

Each of the next n lines contains an integer number wi (1 <= wi <= 10^9) - the width of i-th announcement.

Output
For each announcement (in the order they are given in the input file) output one number - the number of the row in which this announcement is placed. Rows are numbered from 1 to h, starting with the top row. If an announcement can't be put on the billboard, output "-1" for this announcement.

Sample Input
  
  
3 5 5 2 4 3 3 3

Sample Output
  
  
1 2 1 3 -1

Author
hhanger@zju

Source

Recommend
lcy
当h>n时只需要开n大小的线段树即可
 
 
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 200100
using namespace std;
class node
{
  public:
  int l,r,ma;
}root[4*N];
int n,q;
int M;
void build(int t,int l,int r,int m)
{
  root[t].l=l;root[t].r=r;
  if(root[t].l==root[t].r)root[t].ma=m;
  else
  {
    build(t<<1,l,(l+r)/2,m);build(t<<1|1,(l+r)/2+1,r,m);
    root[t].ma=max(root[t<<1].ma,root[t<<1|1].ma);
  }
}
void update(int t,int pos)
{
  int s;
  if(root[t].l==root[t].r&&root[t].ma>=pos){M=root[t].l;root[t].ma-=pos;return;}
  if(root[t].ma<pos){return;}
  else
  {
    if(root[t<<1].ma>=pos)update(t<<1,pos);
    else update(t<<1|1,pos);
    root[t].ma=max(root[t<<1].ma,root[t<<1|1].ma);
  }
}
int main()
{
  int m,a;
  while(scanf("%d%d%d",&n,&m,&q)!=EOF)
  {
    if(n>N)
    n=N-10;
    build(1,1,n,m);
    for(int i=0;i<q;i++)
    {
      M=-1;
      scanf("%d",&a);
      update(1,a);
      printf("%d\n",M);
    }
  }
}

03-10
&lt;think&gt;嗯,用户想获取关于GEEGoogle Earth Engine)的星系信息和资源,特别是与数据处理和遥感相关的内容。首先,我需要确认&ldquo;星系&rdquo;在这里的具体含义。可能用户指的是卫星数据,比如不同卫星的数据集,或者天文方面的星系数据?但结合上下文中的引用内容,GEE主要用于地球观测,比如Landsat、Sentinel等卫星数据,而不是天文星系。所以可能用户有笔误,或者想了解GEE中的卫星数据资源。 接下来,我需要参考用户提供的引用内容。引用[1]和[2]详细介绍了GEE的功能,包括其处理遥感数据的能力,支持的数据集如MODIS、Landsat、Sentinel,以及气象数据。引用[3]提到了上传矢量数据的问题,可能涉及数据处理中的常见错误。用户的问题核心应该是如何在GEE中处理这些卫星数据,以及可用的资源。 根据系统级指令,回答需要结构清晰,分步骤解决问题。首先应该介绍GEE中可用的卫星数据集,然后说明数据处理的基本流程,再给出代码示例,最后生成相关问题。同时,要确保所有数学公式和代码块格式正确,使用中文回答,并添加引用标识。 需要检查是否有遗漏的关键点,比如GEE的数据访问方式、API使用、常见问题解决(如引用[3]中的上传错误)。另外,用户提到&ldquo;星系&rdquo;,可能需要确认是否涉及多源数据融合或时间序列分析,这在遥感处理中是常见的应用,可以适当扩展。 最后,生成的相关问题需要围绕GEE数据处理、应用场景、技术优势等,确保问题具有针对性和延伸性,帮助用户进一步探索。&lt;/think&gt;### GEEGoogle Earth Engine)卫星数据处理与遥感应用 #### 1. GEE支持的卫星数据集 GEE集成了超过1000个公共数据集,覆盖地球科学领域的多源遥感数据,包括: - **Landsat系列**:提供1972年至今的全球中分辨率影像,支持地表覆盖长期监测[^2]。 - **Sentinel系列**:包含高分辨率雷达(Sentinel-1)和多光谱影像(Sentinel-2),适用于精准农业和灾害监测。 - **MODIS**:每日更新的全球植被指数(NDVI)和地表温度数据,公式为: $$ \text{NDVI} = \frac{\text{NIR} - \text{Red}}{\text{NIR} + \text{Red}} $$ - **气象数据**:如NCEP再分析数据,提供温度、降水等参数的时间序列分析。 #### 2. 数据处理流程示例 以下为GEE中计算NDVI的典型代码框架: ```javascript var sentinel2 = ee.ImageCollection(&#39;COPERNICUS/S2_SR_HARMONIZED&#39;) .filterDate(&#39;2023-01-01&#39;, &#39;2023-12-31&#39;) .filterBounds(geometry); var ndvi = sentinel2.map(function(image) { return image.normalizedDifference([&#39;B8&#39;, &#39;B4&#39;]).rename(&#39;NDVI&#39;); }); Map.addLayer(ndvi.mean(), {min:0, max:1, palette:[&#39;white&#39;, &#39;green&#39;]}, &#39;NDVI&#39;); ``` 此脚本完成时间序列NDVI计算与可视化,利用云端计算避免数据下载[^2]。 #### 3. 独特技术优势 - **海量数据处理**:单次运算可处理PB级数据,如全球30米分辨率土地覆盖分类 - **时序分析能力**:支持$(\text{imageCollection.filterDate()})$快速构建时间序列 - **算法集成**:内置$(\text{ee.Reducer()})$统计模块,可计算均值、方差等指标 #### 4. 典型应用场景 | 领域 | 数据组合 | 算法案例 | |------------|------------------------------|------------------------------| | 农业监测 | Sentinel-2 + MODIS | 作物分类(随机森林算法) | | 森林火灾 | Landsat-8 + VIIRS热点数据 | 燃烧指数计算$(\text{NBR})$ | | 城市扩张 | 夜间灯光数据 + Landsat | 主成分分析(PCA) |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值