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

#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. 济南清北学堂游记 Day 6.

    还剩一天半我就该回去了. 说实话今天挺可惜的,有很多本来可以得到的分数评测时没有拿到.上午的第一题和第二题我都想出了正解,T3敲了一个暴力,虽然暴力写坏了.预计是可以拿210的但是实际上只有很少的分数 ...

  2. bzoj 4871: [Shoi2017]摧毁“树状图” [树形DP]

    4871: [Shoi2017]摧毁"树状图" 题意:一颗无向树,选两条边不重复的路径,删去选择的点和路径剩下一些cc,求最多cc数. update 5.1 : 刚刚发现bzoj上 ...

  3. BZOJ 4710: [Jsoi2011]分特产 [容斥原理]

    4710: [Jsoi2011]分特产 题意:m种物品分给n个同学,每个同学至少有一个物品,求方案数 对于每种物品是独立的,就是分成n组可以为空,然后可以用乘法原理合起来 容斥容斥 \[ 每个同学至少 ...

  4. BZOJ 3514: Codechef MARCH14 GERALD07加强版 [LCT 主席树 kruskal]

    3514: Codechef MARCH14 GERALD07加强版 Time Limit: 60 Sec  Memory Limit: 256 MBSubmit: 1312  Solved: 501 ...

  5. ArcGIS API for JavaScript开发环境搭建与发布以及基本功能实现

    1.背景介绍 ArcGIS API for JavaScript 咱这就不介绍了,具体可看ESRI中国的介绍:http://support.esrichina.com.cn/2011/0223/960 ...

  6. Angular+ionic2+Echarts 实现图形制作,以饼图为例

    step1:添加插件echart; npm install echarts --save package.json文件中会在dependencies中添加echarts,如下图: step2:运行cm ...

  7. JSON工具类

    import java.sql.Timestamp; import java.util.Collection; import java.util.Date; import org.soul.util. ...

  8. Netty的常用概念

    我们先来看一段代码: // Configure the server. EventLoopGroup bossGroup = new NioEventLoopGroup(1); EventLoopGr ...

  9. bower使用入门

    1.什么是bower Bower是一个客户端技术的软件包管理器,它可用于搜索.安装和卸载如JavaScript.HTML.CSS之类的网络资源.其他一些建立在Bower基础之上的开发工具,如YeoMa ...

  10. Ubantu16.04 redis安装

    通过FTP方式将redis的安装包从windows上传到linux上 解压命令:$sudo tar -zxf ~/Downloads/redis-3.2.7.tar.gz -C /usr/local ...