hihocoder1391 Country
题解的那种前缀和以前没学过,感觉是种套路
#include<bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int MAXN = 1e4+5;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
int Ta,Tb,X;
int N,M;
struct Node{
int st,ti,da;
void inpu() {
scanf("%d %d %d",&st,&ti,&da);
}
}A[MAXN],B[MAXN*2];
map<int,int> mp;
map<int,int>::iterator it;
int main(){
while(~scanf("%d %d %d",&Ta,&Tb,&X)) {
mp.clear();
scanf("%d %d",&N,&M);
int tot = 0; int ans;
for(int i = 1; i <= N; ++i) A[i].inpu();
for(int i = 1; i <= M; ++i) B[i].inpu();
int st = X; int ed = X+Tb;
for(int i = 1; i <= N; ++i) {
if(A[i].st+A[i].ti >= st && A[i].st+A[i].ti <= ed) {
B[++M].st = A[i].st+A[i].ti; B[M].ti = A[i].ti; B[M].da = A[i].da;
}
}
for(int i = 1; i <= M; ++i) {
tot += B[i].da; int k = 0;
if(B[i].st+2*B[i].ti >= st && B[i].st+2*B[i].ti <= ed) {
k = (ed-B[i].st-2*B[i].ti)/2/B[i].ti + 1;
}
int t1 = B[i].st+B[i].ti; int t2 = t1+2*k*B[i].ti;
if(t2-Ta < t1+1) {
mp[t2-Ta] -= B[i].da; mp[t1+1] += B[i].da;
}
}
ans = tot;
for(it = mp.begin(); it != mp.end(); ++it) {
tot += it->second;
ans = min(ans,tot);
}
printf("%d\n",ans);
}
return 0;
}
hihocoder1391 Country的更多相关文章
- wifi的country code
转自:http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.htmlCountry A 2 A 3 Number ------------- ...
- ural 1073. Square Country
1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...
- 最小生成树 kruskal hdu 5723 Abandoned country
题目链接:hdu 5723 Abandoned country 题目大意:N个点,M条边:先构成一棵最小生成树,然后这个最小生成树上求任意两点之间的路径长度和,并求期望 /************** ...
- hihocoder-1391&&北京网赛09 Countries(优先队列)
题目链接: Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, country ...
- 01背包 URAL 1073 Square Country
题目传送门 /* 题意:问n最少能是几个数的平方和 01背包:j*j的土地买不买的问题 详细解释:http://www.cnblogs.com/vongang/archive/2011/10/07/2 ...
- 计算机学院大学生程序设计竞赛(2015’12)The Country List
The Country List Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) ...
- HDU 5723 Abandoned country(落后渣国)
HDU 5723 Abandoned country(落后渣国) Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/65536 ...
- HDU 5723 Abandoned country (最小生成树 + dfs)
Abandoned country 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5723 Description An abandoned coun ...
- [转]How to convert IP address to country name
本文转自:http://www.codeproject.com/Articles/28363/How-to-convert-IP-address-to-country-name Download ...
随机推荐
- HDU 5996 dingyeye loves stone [阶梯Nim]
dingyeye喜欢和你玩石子游戏. dingyeye有一棵nn个节点的有根树,节点编号为00到n−1n−1,根为00号节点.游戏开始时,第ii个节点上有a[i]a[i]个石子.两位玩家轮流操作,每次 ...
- [2-SAT]【学习笔记】【未完】
这种一看就很2的东西.... 参考资料: 由对称性解2-sat问题 2-sat解法浅析 $SAT$理论: $2-SAT$ 两种形式: $x \in \hat B$ $x \lor y(x,\ y \i ...
- SqlServer循环 和 批量倒数据
SqlServer循环语句 declare @i int set @i =1 while(@i<5) begin set @i = @i+1 insert into text(id,name ...
- 本地创建yum源并安装lnmp
注意:安装系统时,文件类型要未xfs类型,root要分配最多的空间 1.挂载安装光盘mount -t iso9660 -o loop CentOS-7-x86_64-DVD-1511.iso /mnt ...
- 在 CentOS7.0 上搭建 Chroot 的 Bind DNS 服务器
BIND(Berkeley internet Name Daemon)也叫做NAMED,是现今互联网上使用最为广泛的DNS 服务器程序.这篇文章将要讲述如何在 chroot 监牢中运行 BIND,这样 ...
- [poj3565]Ants
[poj3565]Ants 标签(空格分隔):二分图 描述 Young naturalist Bill studies ants in school. His ants feed on plant-l ...
- 抛砖引玉之~sftp
跨平台系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#linux XFtp用惯了,没有它就不行了?Linux就不能文件传输了? 答案肯定是~No ...
- 【记录】.net 通用log4net日志配置
asp.net mvc 1.引入log4netNuGet包. 2.修改Global.asax下的Application_Start方法.加入log4net.Config.XmlConfigurator ...
- Eclipse中如何忽略报错的js文件
https://jingyan.baidu.com/article/4f7d5712d3701a1a20192786.html
- sqlite不存在记录则插入数据
问题:如下图在Sqlite数据库中存在一张Student表,现需要向表中插入数据,如果不存在同名记录则插入,否则不进行插入操作. 解答:利用not exists语句,如下: insert into [ ...