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 ...
随机推荐
- MySQL dump简单使用
首先确保MySQL的bin目录已经添加到path中,在cmd中运行@echo %path%查看. 1.基本的mysqldump使用: mysqldump -uroot -pOSSDB123 nnm5 ...
- POJ 3182 The Grove [DP(spfa) 射线法]
题意: 给一个地图,给定起点和一块连续图形,走一圈围住这个图形求最小步数 本来是要做课件上一道$CF$题,先做一个简化版 只要保证图形有一个点在走出的多边形内就可以了 $hzc:$动态化静态的思想,假 ...
- BZOJ 3544: [ONTAK2010]Creative Accounting [set]
给定一个长度为N的数组a和M,求一个区间[l,r],使得$(\sum_{i=l}^{r}{a_i}) mod M$的值最大,求出这个值,注意这里的mod是数学上的mod 这道题真好,题面连LaTeX都 ...
- BZOJ 3270: 博物馆 [概率DP 高斯消元]
http://www.lydsy.com/JudgeOnline/problem.php?id=3270 题意:一张无向图,一开始两人分别在$x$和$y$,每一分钟在点$i$不走的概率为$p[i]$, ...
- Windows Server 2016-部署RODC只读域控制器
只读域控制器Read-Only Domain Controller简称RODC.RODC是Windows Server 2008之后引入的一活动目录特性,与其他域控制器一样包含AD数据库,但RODC默 ...
- 01 Mybatis 的配置和使用
一.Mybatis 是什么 MyBatis 是一个支持普通SQL查询.存储过程和高级映射的优秀持久层框架.MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及对结果集的检索封装.MyB ...
- 使用Dism备份和全新恢复系统
1.使用WinPE启动,winPE制作可以参考我的另一文章http://www.cnblogs.com/karl-F/p/6934086.html 2.捕获C盘镜像 (1)查看磁盘 在PE提示符:输入 ...
- PLECS—模型仿真——第十一周作业
1. 直流电机单闭环调速系统比例控制仿真 (1)整体电路图 (2)控制部分电路图 (3)参数设置+仿真结果 2. 直流电机单闭环调速系统比例积分控制仿真 (1)参数设置 (2)仿真结果 3. 直流电机 ...
- LearnPython_week2
1. 列表.元组 2. 字典 3. 集合 4. 字符串的各种姿势 5. OPEN文件操作 1. 列表.元组 列表 names = ['wong','caiyun',' ...
- FTP主动模式和被动模式
FTP主动模式和被动模式 FTP是仅基于TCP的服务,不支持UDP.与众不同的是FTP使用2个端口,一个数据端口和一个命令端口(也可叫做控制端口).通常来说这两个端口是21(命令端口)和20(数据端口 ...