Codeforces 912C Perun, Ult!
恶心题, 好多细节。。。 啊, 好恶心啊。
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long using namespace std; const int N = 1e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = ;
const double eps = 1e-;
const double PI = acos(-); int n, m;
vector<PLL> vc[N];
vector<LL> prefix[N];
vector<LL> gg;
LL bou, inc, dam;
LL maxh[N], starth[N], regen[N];
vector<LL> oo;
vector<LL> cnt;
vector<PLL> add; int getPos(LL x) {
return lower_bound(oo.begin(), oo.end(), x) - oo.begin();
} int main() {
scanf("%d%d", &n, &m);
scanf("%lld%lld%lld", &bou, &inc, &dam);
for(int i = ; i <= n; i++) {
scanf("%lld%lld%lld", &maxh[i], &starth[i], ®en[i]);
vc[i].push_back(mk(, starth[i]));
}
for(int i = ; i <= m; i++) {
LL x, y, z; scanf("%lld%lld%lld", &x, &y, &z);
vc[y].push_back(mk(x, z));
}
for(int i = ; i <= n; i++) {
if(maxh[i] <= dam && inc) {
puts("-1");
return ;
}
}
for(int i = ; i <= n; i++) sort(vc[i].begin(), vc[i].end());
for(int i = ; i <= n; i++) {
for(int j = ; j < SZ(vc[i]); j++) {
LL up = j < SZ(vc[i]) - ? vc[i][j + ].fi - : INF;
if(vc[i][j].se > dam) continue;
if(regen[i]) {
LL ret = (dam - vc[i][j].se) / regen[i];
add.push_back(mk(vc[i][j].fi, min(up, vc[i][j].fi + ret)));
oo.push_back(vc[i][j].fi);
oo.push_back(min(up, vc[i][j].fi + ret) + );
} else {
if(up == INF && inc) {
puts("-1");
return ;
} else {
add.push_back(mk(vc[i][j].fi, up));
oo.push_back(vc[i][j].fi);
oo.push_back(up + );
}
}
}
}
LL ans = ;
sort(oo.begin(), oo.end());
oo.erase(unique(oo.begin(), oo.end()), oo.end());
cnt.resize(SZ(oo));
for(auto& t : add) {
cnt[getPos(t.fi)]++;
cnt[getPos(t.se + )]--;
}
for(int i = ; i < SZ(cnt); i++) {
if(i) cnt[i] += cnt[i - ];
ans = max(ans, 1LL * cnt[i] * (bou + (oo[i + ] - ) * inc));
}
printf("%lld\n", ans);
return ;
} /*
*/
Codeforces 912C Perun, Ult!的更多相关文章
- 【Codeforces Round #456 (Div. 2) C】Perun, Ult!
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...
- Codeforces Round #456 (Div. 2)
Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
随机推荐
- web@css普通布局 , 高级布局 , 布局坑
1.高级布局<文档流概念>:页面从上至下,块式标签一行一行排列,内联式一行中从左至右排列<BFC规则>:左右位置(左右margin)垂直位置(上下margin)容器内外(互不影 ...
- Zookeeper-Watcher机制与异步调用原理
转载于:http://shift-alt-ctrl.iteye.com/blog/1847320 Watcher机制:目的是为ZK客户端操作提供一种类似于异步获得数据的操作. 1)在创建Zookeep ...
- 前端-----margin用法(盒子模型里补充)
margin塌陷问题 当时说到了盒模型,盒模型包含着margin,为什么要在这里说margin呢?因为元素和元素在垂直方向上margin里面有坑. 我们来看一个例子: html结构: <div ...
- oracle里面用sql做报表并带小计合计常用到的函数
1-- DECODE函数是Oracle PL/SQL是功能强大的函数之一,假设我们想给职员加工资,其标准是:工资在8000元以下的将加20%:工资在8000元以上的加15%,通常的做法是,先选出记录 ...
- textarea的高度随内容变化而变化
<li class="text"> <span>参赛宣言*</span> <textarea name="txt" i ...
- vue----less引用
1.安装less. npm install less less-loader --save-dev 2.修改webpack.config.js { test: /\.less$/, use:[ 'st ...
- (转载)(int)a、&a、(int)&a、(int&)a的区别,很偏僻的题
#include <iostream>#include <stdio.h>#include <string.h>#include <conio.h>us ...
- 基于C#net4.5websocket客户端与服务端
只支持win8以上系统以及windows server2012以上系统 最近在研究视频传输给浏览器,然后使用H5标签解码.视频流采用websocket传输.所以研究了一下C#的websocket. 首 ...
- centos7_ linux : Nginx安装手册
一: nginx安装环境 1: oracle vm虚拟机+Centos7系统的yum环境的安装 配置本地yum库(用root用户操作) 创建挂载目录 mkdir /mnt/cdrom 查看挂载目录 l ...
- Confluence 6 升级自定义的站点和空间仔细测试你的修改
修改可能对 Confluence 的后续版本不兼容,当你对 Confluence 进行升级的时候,你应该总是对你自定义修改的模板文件进行仔细的测试来确定所有的修改对新版本的 Confluence 兼容 ...