【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

set1 > set1;记录关键点->某个人怪物永远打不死了,第一维是时间,第二维是下标

int dic[1e5+10] //记录对应下标的怪物它此时此刻在何时打不死了

set2 < pair< int,int > > set2;关键点2->有怪物要更新了的时间点,以及记录的信息下标idx2

之所以这样记录。是为了尽可能多地让怪物存活时间长一点

if (start > damage) continue;else

//special表示这个怪物一直能被打死。

//delta表示目前为止一直能被打死的怪物的个数

if (max_h <= damage ||(start<=damage && rec==0)) {delta++; special[i] = 1;continue;}else{

int time = damage-start/rec;->取整数部分就可以了

set1.insert(time,idx);

dic[idx] = time;

}

set2.insert(timej,j);

set1和set2里面找关键点。
先找小的时间mi 如果是set1的话
temp = set1.size();
if (上一个时间和这个时间相同) temp = 上一次set1的size()
ans = max(ans,(temp+delta)*(chushi+mi*increase));
然后删掉set1.begin(); 如果是set2的话
因为可能经过这次更新之后某些怪物的曲线变了。
则在变之前先尝试更新一下答案。
时间是t2-1
num = (ll)set1.size();
ans = max(ans,(num+delta)*(bounty+(t2-1)*increase)); int idx = enemy[set2.begin().second];
pair<dic[idx],idx>;
从set1中删掉这个东西->如果有
if (special[idx]==1) delta--;
if (health>damage) continue;
if (maxh<=damage ||(updateheadl<=damage && rec==0)) {delta++;special[idx] = 1;continue;else{
int time = (damage-update)/rec
set1.insert(timebegin+time,idx)
} 最后统计special的个数cnt

如果cnt>0且increase!=0 那么输出无限大

否则increase==0 则 再用cnt*bounty和ans比一下取较大值;->防止没有更新操作的时候一次ans都没有取到

【代码】

#include <bits/stdc++.h>
#define ll long long
#define time mytime
using namespace std; const int N = 1e5; set<pair<ll,int> > set1,set2;
int n,m;
ll bounty,increase,damage;
ll max_h[N+10],start_h[N+10],regen[N+10];
ll time[N+10],enemy[N+10],health[N+10],dic[N+10],delta = 0;
bool special[N+10]; int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
memset(dic,255,sizeof dic);
cin >> n >> m;
cin >> bounty >> increase >> damage;
for (int i = 1;i <= n;i++){
cin >> max_h[i] >> start_h[i] >> regen[i]; if (start_h[i]>damage) continue;
if (max_h[i]<=damage ||(start_h[i]<=damage && regen[i]==0)){
special[i] = 1;
delta++;
continue;
}
ll time = (damage-start_h[i])/regen[i];
dic[i] = time;
set1.insert({time,i});
} for (int i = 1;i <= m;i++){
cin >> time[i] >> enemy[i] >> health[i];
set2.insert({time[i],i});
} ll ans = 0;
int pre = -1;
ll prenum = 0;
while (!set1.empty() || !set2.empty()){
ll t1 = -1,t2 = -1;
if (!set1.empty()) t1 = (*set1.begin()).first;
if (!set2.empty()) t2 = (*set2.begin()).first;
//等于的话先处理更新的
if (t1!=-1 &&(t2==-1 || t1 <t2)){
ll time2 = (*set1.begin()).first;
ll num = (ll)set1.size();
if (pre!=-1 && time2==pre){
num = prenum;
}else {
pre = time2;
prenum = num;
}
ans = max(ans,(num+delta)*(bounty+t1*increase));
set1.erase(set1.begin());
}else{
ll num = (ll)set1.size();
ans = max(ans,(num+delta)*(bounty+(t2-1)*increase)); int tempidx = (*set2.begin()).second;
set2.erase(set2.begin());
int idx =enemy[tempidx];
auto it = set1.upper_bound({dic[idx],idx});
if (it!=set1.begin()){
it--;
pair<ll,int> temp = (*it);
if (temp.first==dic[idx] && temp.second==idx){
set1.erase(it);
}
} if (special[idx]) delta--;
special[idx] = 0;
dic[idx] = -1;
if (health[tempidx]>damage) continue;
if (max_h[idx]<=damage ||(health[tempidx]<=damage && regen[idx]==0)){
special[idx] = 1;
delta++;
continue;
} else{
ll time1 = (damage-health[tempidx])/regen[idx];
dic[idx] = time[tempidx] + time1;
set1.insert({dic[idx],idx});
}
}
} int cc =0;
for (int i = 1;i <= n;i++)
if (special[i])
cc++;
if (cc>0 && increase>0)
return cout<<-1,0;
else ans = max(ans,(ll)cc*bounty);
cout << ans << endl;
return 0;
}

【Codeforces Round #456 (Div. 2) C】Perun, Ult!的更多相关文章

  1. 【Codeforces Round #456 (Div. 2) A】Tricky Alchemy

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 统计需要的个数. 不够了,就买. [代码] #include <bits/stdc++.h> #define ll lo ...

  2. 【Codeforces Round #456 (Div. 2) B】New Year's Eve

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 显然10000..取到之后 再取一个01111..就能异或成最大的数字了. [代码] /* 1.Shoud it use long ...

  3. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  4. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  5. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  6. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

  7. 【Codeforces Round #423 (Div. 2) C】String Reconstruction

    [Link]:http://codeforces.com/contest/828/problem/C [Description] 让你猜一个字符串原来是什么; 你知道这个字符串的n个子串; 且知道第i ...

  8. 【Codeforces Round #423 (Div. 2) B】Black Square

    [Link]:http://codeforces.com/contest/828/problem/B [Description] 给你一个n*m的格子; 里面包含B和W两种颜色的格子; 让你在这个格子 ...

  9. 【Codeforces Round #423 (Div. 2) A】Restaurant Tables

    [Link]:http://codeforces.com/contest/828/problem/A [Description] 有n个组按照时间顺序来餐馆; 每个组由一个人或两个人组成; 每当有一个 ...

随机推荐

  1. Https个人总结

    花了一个星期终于搞懂了.. HTTPS个人总结: 一.RSA算法 公钥:可以分发给任意的钥匙 私钥:自己保留起来,不分发给别人的钥匙 RSA算法: 找出质数p.q n = p*q Φ(n)=(p-1) ...

  2. NodeJS学习笔记 (30)定时器-timers

    https://github.com/chyingp/nodejs-learning-guide

  3. 记intel杯比赛中各种bug与debug【其三】:intel chainer的安装与使用

    现在在训练模型,闲着来写一篇 顺着这篇文章,顺利安装上intel chainer 再次感谢 大黄老鼠 intel chainer 使用 头一次使用chainer,本以为又入了一个大坑,实际尝试感觉非常 ...

  4. Windows10通过VNC远程连接Ubuntu18.04

    1.打开终端输入:sudo apt-get install xrdp vnc4server xbase-clients dconf-editor 2.接着在终端输入: 进入到下面这个界面: 接着按照这 ...

  5. ifsta---统计网络接口活动状态

    ifstat命令就像iostat/vmstat描述其它的系统状况一样,是一个统计网络接口活动状态的工具.ifstat工具系统中并不默认安装,需要自己下载源码包,重新编译安装,使用过程相对比较简单. 下 ...

  6. python之禅---对象与元类

    众所周知,python是一门面向对象的编程语言,python中一切皆对象,那么我们先探讨一下什么是对象. 一.对象 在生活中一个事物就是一个对象,比如:一只猫就是一个对象,猫的体型.猫毛的颜色等是它的 ...

  7. cmder-替代cmd

    之所以选择cmder,说来话长,在学习python的过程中,由于经常通过pip命令安装包,并且在学习一些包的使用例如virtualenv,教程贴都是在终端下的命令,这使我对cmd的使用频率慢慢变多了起 ...

  8. caioj 1076 动态规划入门(中链式3:最大的算式)

    一开始写了一个复杂度很大的方法,然后还过了(千万记得开longlong ) #include<cstdio> #include<cstring> #include<alg ...

  9. 7. java操作MongoDB,采用_id查询

    转自:https://www.2cto.com/database/201704/633262.html mongodb命令行_id查询方法 直接用ObjectId() db.getCollection ...

  10. Spring MVC -- UEditor 编辑器整合 上传图片至外部文件夹(非项目文件夹)

    上传图片到外部储存,回显图片 下载全部UEditor资源源码 config.json配置 config.json中添加如下属性 (一定要添加此属性): "physicsPath": ...