题解的那种前缀和以前没学过,感觉是种套路

#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的更多相关文章

  1. wifi的country code

    转自:http://userpage.chemie.fu-berlin.de/diverse/doc/ISO_3166.htmlCountry A 2 A 3 Number ------------- ...

  2. ural 1073. Square Country

    1073. Square Country Time limit: 1.0 secondMemory limit: 64 MB There live square people in a square ...

  3. 最小生成树 kruskal hdu 5723 Abandoned country

    题目链接:hdu 5723 Abandoned country 题目大意:N个点,M条边:先构成一棵最小生成树,然后这个最小生成树上求任意两点之间的路径长度和,并求期望 /************** ...

  4. hihocoder-1391&&北京网赛09 Countries(优先队列)

    题目链接: Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, country ...

  5. 01背包 URAL 1073 Square Country

    题目传送门 /* 题意:问n最少能是几个数的平方和 01背包:j*j的土地买不买的问题 详细解释:http://www.cnblogs.com/vongang/archive/2011/10/07/2 ...

  6. 计算机学院大学生程序设计竞赛(2015’12)The Country List

    The Country List Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

  7. HDU 5723 Abandoned country(落后渣国)

    HDU 5723 Abandoned country(落后渣国) Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  8. HDU 5723 Abandoned country (最小生成树 + dfs)

    Abandoned country 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5723 Description An abandoned coun ...

  9. [转]How to convert IP address to country name

    本文转自:http://www.codeproject.com/Articles/28363/How-to-convert-IP-address-to-country-name   Download ...

随机推荐

  1. 《Thinking in Java》学习笔记(六)

    1.Class相关知识 Class类可以理解为类的图纸,通过Class类可以分析类的结构.构建出类的实例. Class.forName("test.TestClass").newI ...

  2. WPF 圆角输入框

    今天打算来做一个圆角的输入框 默认输入框: 这个输入框不好看,并且在XP 跟 WIN 7  WIN10 效果 都不太一样 我们今天不用模板的方式,而是 最简单的方式 来实现 圆角 输入框: ----- ...

  3. CentOS 7 安装 Nginx 反向代理 node

    安装 nginx yum install epel-release yum install nginx 配置 nginx sudo vim /etc/nginx/nginx.conf, 改成下面配置: ...

  4. php正则判断字符串是否含有中文

    <?php $str = '若你安好便是晴天'; if (preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)>0) { echo '全是中文'; } ...

  5. 微信小程序初识

    http://lib.csdn.net/article/wechat/46742 微信小程序的前途和定位有什么疑惑?点进去 简单先记几个印象名词:流量入口,线下是重点,“即用即走”适合低频工具类产品. ...

  6. Java中Excel表格的上传与下载

    详见:http://blog.csdn.net/lzh657083979/article/details/73252585

  7. Jquery那些坑

    今天写Jquery的时候突然发现在将$("<td><td/>").appendTo(someElement)的时候发现一下子多出来两个,甚是奇怪,检查后端和 ...

  8. hibhibernate中hql中的语句where语句查询List出现空

    1.java.sql.Date 与 java.util.Date java.sql.Date是从java.util.Date中继承而来 假设 dates1(java.sql.Date)要赋值给date ...

  9. Qt Creator 整合 python 解释器教程

    目录 1. 前言 2.前提条件 3.步骤 3.1 新建 python文件 3.2 编写 python 代码 3.3 配置 python 解释器 3.4 执行 python file 1. 前言 Pyt ...

  10. hive:join操作

    hive的多表连接,都会转换成多个MR job,每一个MR job在hive中均称为Join阶段.按照join程序最后一个表应该尽量是大表,因为join前一阶段生成的数据会存在于Reducer 的bu ...