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 ...
随机推荐
- css和javascript代码写在页面中的位置说明
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- MySQL新增多个字段
alter table pic_all add ( `expand1` ), `expand2` ), `expand3` ) );
- var_export 掉咋天
var_export 文件缓存经常使用 输出或返回一个变量的字符串表示 /** * 写入缓存 * * @param string $id * @param mixed $data * @ ...
- Android获取本机号码及运营商
import android.content.Context; import android.telephony.TelephonyManager; import android.util.Log; ...
- PHP中empty,isset,is_null的区别
isset 判断变量是否已存在 empty 判断变量是否为空或为0 is_null 判断变量是否为NULL 仅作为记录使用. 参考链接:http://www.jb51.net/article/6903 ...
- [图形]图形API的两种模式
图形API可以分为retained-mode APIs(保存模式API)和immediate-mode APIs(中间模式API). Direct2D是immediate-mode API,而Wind ...
- PHP中使用Redis长连接笔记
pconnect函数声明 其中time_out表示客户端闲置多少秒后,就断开连接.函数连接成功返回true,失败返回false: pconnect(host, port, time_out, pers ...
- 修改html中button显示的文字
1. <input type="button"> 实现密码输入框的可见和隐藏 直接修改value属性即可 <script type="text/jav ...
- The word 'localhost' is not correctly spelled 这个问题怎么解决
The word 'localhost' is not correctly spelled 这个问题怎么解决 有时工程中有下划线并提示 The word is not correctly spelle ...
- Java 8 中的 Lambda 表达式
Lambda 表达式是 Java 8 最受欢迎的功能.人们将函数式编程的概念引入了 Java 这门完全面向对象的命令式编程语言. 关于函数式编程是如何运作的,这个话题超出了本文的范围,不过我们会提炼出 ...