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], &regen[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!的更多相关文章

  1. 【Codeforces Round #456 (Div. 2) C】Perun, Ult!

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] set1 < pair < int,int > > set1;记录关键点->某个人怪物永远打不死了,第 ...

  2. Codeforces Round #456 (Div. 2)

    Codeforces Round #456 (Div. 2) A. Tricky Alchemy 题目描述:要制作三种球:黄.绿.蓝,一个黄球需要两个黄色水晶,一个绿球需要一个黄色水晶和一个蓝色水晶, ...

  3. python爬虫学习(5) —— 扒一下codeforces题面

    上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...

  4. 【Codeforces 738D】Sea Battle(贪心)

    http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...

  5. 【Codeforces 738C】Road to Cinema

    http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...

  6. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  7. CodeForces - 662A Gambling Nim

    http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...

  8. CodeForces - 274B Zero Tree

    http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...

  9. CodeForces - 261B Maxim and Restaurant

    http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...

随机推荐

  1. node.js总结

    1.NPM安装报错:no such file or directory, open 'C:\Users\HP\package.json' npm WARN saveError ENOENT: no s ...

  2. 51nod--1212 最小生成树

    题目: 1212 无向图最小生成树 基准时间限制:1 秒 空间限制:131072 KB 分值: 0 难度:基础题 收藏 关注 N个点M条边的无向连通图,每条边有一个权值,求该图的最小生成树. Inpu ...

  3. python 初识函数

    1.什么是函数 函数就是对一个代码块 或者功能的封装,什么时候用,什么时候执行 语法: def  函数名():            函数体(代码块) 函数的调用 函数名()          #所有 ...

  4. 【原创】大叔问题定位分享(32)mysql故障恢复

    mysql启动失败,一直crash,报错如下: 2019-03-14T11:15:12.937923Z 0 [Note] InnoDB: Uncompressed page, stored check ...

  5. C# pdf转word

    引用组件 Spire.Pdf,去官网下载安装,在bin目录里面有需要的dll文件. static void Main(string[] args) { #region Pdf转word PdfDocu ...

  6. jquery中的attr与prop的区别,什么时候用attr,什么时候用prop

    只要有 Boolean() 属性的,简单说就是具有true 和 false 两个属性的属性,如 checked, selected 或者 disabled 使用prop(),(其实这些都是表单类的), ...

  7. 体验go语言的风骚式编程

    最近想搞搞后台开发,话说注意力就转移到了公司用的golang.用Go做微服务比较方便,或许是因为golang强悍的语法吧,看到go的语法,自己已被深深的吸引.关于学习后台如何选择可以参考<做后台 ...

  8. MONGODB数据基础与命令

  9. 对于stark(curd)插件的使用简单介绍

    一.创建表 from django.db import models from django.db import models class Department(models.Model): &quo ...

  10. 【rabbitmq】安装卸载

    安装: 1. 在http://www.rabbitmq.com/install-rpm.html下载对应系统的rpm包  我下载的是rabbitmq-server-3.6.6-1.el6.noarch ...