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. mysql多表关联update修改操作

      UPDATE province_yunnan_salary s1 JOIN province_guangdong_salary s2 ON s1.user_name= s2.user_name S ...

  2. luasocket 安装记录 (FS1.6)

    说明: 想通过Lua 脚本实现 http.默认 FS 的 mod_lua 中没有对socket 的支持,如下的操作为lua 添加 socket的支持. 一.下载 luasocket 包: # wget ...

  3. 前端 ----jQuery的动画效果

    03-jQuery动画效果   jQuery提供的一组网页中常见的动画效果,这些动画是标准的.有规律的效果:同时还提供给我们了自定义动画的功能. 显示动画 方式一: $("div" ...

  4. django配置发送邮箱

    该邮箱配置后台发送邮箱验证使用 settings内配置 # 服务器地址 EMAIL_HOST = 'smtp.163.com' # 端口,邮箱默认动态端口 25 EMAIL_PORT = 25 # 邮 ...

  5. poj1564 Sum It Up dfs水题

    题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...

  6. c#在Excel指定单元格中插入图片

    方法一: /// 将图片插入到指定的单元格位置,并设置图片的宽度和高度./// 注意:图片必须是绝对物理路径/// </summary>/// <param name="R ...

  7. js——类型转换

      总述                   类型转换:显式.隐式(自动) 隐式转换是由编译器自动进行的,基本主要抽象操作有ToPrimitive, ToNumber, ToString, ToBoo ...

  8. Confluence 6 嵌入的 H2 数据库

    为了让你的 Confluence 在安装成功后就可以使用而不需要使用任何外部的数据库,Confluence 使用一个嵌入的 H2 数据库. 当你选择对 Confluence 进行评估和测试的时候,H2 ...

  9. map函数和reduce函数的区别

    ①从参数方面来讲:map()函数: map()包含两个参数,第一个是参数是一个函数,第二个是序列(列表或元组).其中,函数(即map的第一个参数位置的函数)可以接收一个或多个参数.reduce()函数 ...

  10. 反向找related_name以及limit_fields_to

    问题2:客户的添加页面,通过popup创建用户时 解决方案: 如果新创建的用户时:如果是销售部的人,页面才增加 目的是:拿到limit_choices_to,就可以判断了 当有两个Foreignkey ...