【整体二分】——洛谷P3527 [POI2011]MET-Meteors

GO:

整体二分作为一个常考的比较有趣的算法(就是难),可以巧妙的解决一些本来比较复杂的题目(比如静态区间第k大),作为一个oier,掌握整体二分的思想是很有必要的。


 

题目描述

Byteotian Interstellar Union (BIU) has recently discovered a new planet in a nearby galaxy. The planet is unsuitable for colonisation due to strange meteor showers, which on the other hand make it an exceptionally interesting object of study.

The member states of BIU have already placed space stations close to the planet's orbit. The stations' goal is to take samples of the rocks flying by.

The BIU Commission has partitioned the orbit into mm sectors, numbered from 11 to mm, where the sectors 11 and mm are adjacent. In each sector there is a single space station, belonging to one of the nn member states.

Each state has declared a number of meteor samples it intends to gather before the mission ends. Your task is to determine, for each state, when it can stop taking samples, based on the meter shower predictions for the years to come.

输入格式

The first line of the standard input gives two integers, nn and mm (1\le n,m\le 300\ 0001n,m300 000), separated by a single space, that denote,respectively, the number of BIU member states and the number of sectors the orbit has been partitioned into.

In the second line there are mm integers o_ioi (1\le o_i\le n1oin),separated by single spaces, that denote the states owning stations in successive sectors.

In the third line there are nn integers p_ipi (1\le p_i\le 10^91pi109),separated by single spaces, that denote the numbers of meteor samples that the successive states intend to gather.

In the fourth line there is a single integer kk (1\le k\le 300\ 0001k300 000) that denotes the number of meteor showers predictions. The following kk lines specify the (predicted) meteor showers chronologically. The ii-th of these lines holds three integers l_i,r_i,a_ili,ri,ai (separated by single spaces), which denote that a meteor shower is expected in sectors l_i,l_{i+1},...,r_ili,li+1,...,ri(if l_i\le r_iliri) or sectors l_i,l_{i+1},...,m,1,...,r_ili,li+1,...,m,1,...,ri (if l_i>r_i

转载于:https://www.cnblogs.com/Nelson992770019/p/11404843.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值