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

【题意】

在这里输入题意

【题解】

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. 使用 Beego 搭建 Restful API 项目

    1 环境准备 首先你需要在你的环境安装以下软件: go:编程语言运行环境 git:版本控制工具 beego:go 语言流行的开发框架 bee:beego 配套的快速搭建工具 你喜欢的数据库:这里以 M ...

  2. bzoj1230 开关灯 线段树

    好久没写线段树了..被一道线段树裸题卡了一个上午 对区间进行异或,查询的时候直接用区间长度减去原有是数量就是改变完的数量 #include<bits/stdc++.h> using nam ...

  3. [Bug]Python3.x AttributeError: libtest.so: undefined symbol: fact

    写kNN,需要在python中实现kd-tree 思考了一下,在python下写这种算法类的东西,还是十分别扭 于是希望用ctypes调用一下c++动态加载库 于是尝试实现一下 // test.cpp ...

  4. ZJU 1346 Comparing Your Heroes 状态压缩DP 拓扑排序的计数

    做多校的时候遇见一个求拓扑排序数量的题,就顺便来写了一下. 题意: 你有个朋友是KOF的狂热粉丝,他有一个对其中英雄的强弱比较,让你根据这些比较关系来给这些英雄排名.问一共有多少种排名方式. 思路: ...

  5. ArcGIS api for javascript——地理编码任务-反向地理编码

    描述 反向地理编码确定地图上给出点的地址.本例展示了如何通过ArcGIS JavaScript API做反向地理编码. 反向地理编码和常规的地理编码请求都使用Locator类和ArcGIS Serve ...

  6. URAL 1823. Ideal Gas(数学啊 )

    题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1823 1823. Ideal Gas Time limit: 0.5 second Me ...

  7. sqlserver bulk insert

    开启功能 -- To allow advanced options to be changed. EXEC sp_configure 'show advanced options', 1 GO -- ...

  8. 将本地的代码上传到网上SVN库

    使用VisualSVN Server创建版本库: https://jingyan.baidu.com/article/db55b609f6aa724ba20a2f6c.html 最详细的教程: htt ...

  9. MessageFormat

    MessageFormat mf = new MessageFormat("{0,number,#.##}, {0,number,#.#}"); Object[] objs = { ...

  10. Linux 桌面的 Dock 类程序

    1.Cairo-Dock是一个Dock类软件,它支持OpenGL.提供动画及视觉效果的插件.新的Applet.重写配置面板.新增主题等功能. 2.Docky是从GNOME Do项目剥离出来的一个Doc ...