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

【题意】

在这里输入题意

【题解】

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. win下通过pip安装TensorFlow

    官方介绍(超详细):https://www.tensorflow.org/install/pip 按照官方介绍,不同的TensorFlow版本只支持特定的python版本所以你要是下载.whl包安装的 ...

  2. Object-C,四则运算计算器

    下面是是一个比较复杂的类. 定义一个四则运算计算器Caculator的接口和实现. 在main函数中,让用户输入四则运算表达式,比如a+b,a-b. 最后,在控制台输出结果. 用到的语法:接口.类的定 ...

  3. CMSIS-RTOS 时间管理之虚拟定时器Virtual Timers

    虚拟定时器Virtual Timers CMSIS-RTOS API里有几个向下计数的虚拟定时器,它们实现计数完成时用户的回调功能.每个定时器都可以配置成单次计数或重复计数模式,它们可以在定义定时器结 ...

  4. &lt;Machine Learning in Action &gt;之二 朴素贝叶斯 C#实现文章分类

    def trainNB0(trainMatrix,trainCategory): numTrainDocs = len(trainMatrix) numWords = len(trainMatrix[ ...

  5. C. Diverse Permutation(Codeforces Round #275(div2)

    C. Diverse Permutation time limit per test 1 second memory limit per test 256 megabytes input standa ...

  6. iOS App 上架流程

                                                             iPhone App 上架流程 1.  申请 App ID (1)  连到 Devel ...

  7. How to search Installed Updates

    Windows本身的控制面板中自带的搜索,无法根据补丁编号进行搜索 可以将补丁信息导出到文本,再用文本编辑器进行查找 https://www.concurrency.com/blog/w/search ...

  8. .Net 路由处理厉害了

    通过设置路由,可以灵活的显示地址内容.它会自动转换为想要的控制器和方法中去. using System; using System.Collections.Generic; using System. ...

  9. Docker -- 系统整洁之道 -- 0

    在我的小 rmbp 256G的硬盘里,实在是装不下100多个G的虚拟机了,所以想把一些东西迁移到这两年很火的Docker下,Docker以前也有过一两次,只是按着别人给的用法用的,具体的一些细节并没有 ...

  10. Windows10 Linux子系统的启用和中文用户名的修改

    一直用的虚拟机Linux,忽然心血来潮,看到Windows 10可以使用Linux子系统,于是来装一波,按照这位前辈的教程 https://blog.csdn.net/zhangdongren/art ...