当前位置:网站首页>2022 Hangzhou Electric Power Multi-School Session 3 Question B Boss Rush
2022 Hangzhou Electric Power Multi-School Session 3 Question B Boss Rush
2022-08-05 00:22:00 【雨肯定】
题目链接
题目大意
给了我们一个Boss的血量,then gave us n n n个技能,Each skill has a casting time and a casting process time,Inflicts one continuous damage,The question asks when we can finish it soonestBoss?
题解
考虑二分答案,Then we need to make a judgment m i d mid mid时间时,What is the maximum damage that can be done,如果大于等于Boss的血量,那么返回true,否则返回false.When we calculate max damage,Consider the use of shape pressureDP, f [ i ] f[i] f[i]中的 i i i表示一个状态——哪一位为1It represents what skills have been used.The specific state transition can be seen in the code
代码
#include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
#define x first
#define y second
#define int long long
#define endl '\n'
const int inf = 1e9 + 10;
const int maxn = 100010, M = 2000010;
const int mod = 1e9 + 7;
typedef pair<int,int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
int n, H;
int d[20][maxn], s[20][maxn];
int t[20], len[20];
int f[maxn * 3];
bool check(int mid)
{
memset(f, -1, sizeof f);
f[0] = 0;
for(int i = 0; i < 1 << n; i ++){
int time = 0;
for(int j = 0; j < n; j ++){
if(i >> j & 1) time += t[j];
}
if(time > mid) continue;
for(int j = 0; j < n; j ++){
if(i >> j & 1) continue;
f[i | 1 << j] = max(f[i | 1 << j], f[i] + s[j][min(len[j], mid - time)]);
if(f[i | 1 << j] >= H) return true;
}
}
return false;
}
signed main()
{
IOS;
int T; cin >> T;
while(T --)
{
cin >> n >> H;
int l = 0, r = 0;
for(int i = 0; i < n; i ++){
cin >> t[i] >> len[i];
r += max(t[i], len[i]);
for(int j = 1; j <= len[i]; j ++) cin >> d[i][j];
for(int j = 1; j <= len[i]; j ++) s[i][j] = s[i][j - 1] + d[i][j];
}
while(l < r){
int mid = l + r >> 1;
if(check(mid)) r = mid;
else l = mid + 1;
}
if(!check(l)) cout << -1 << endl;
else cout << l - 1 << endl;
}
return 0;
}
边栏推荐
- 【LeetCode】图解 904. 水果成篮
- STC89C52RC的P4口的应用问题
- 10 个关于 Promise 和 setTimeout 知识的面试题,通过图解一次说透彻
- jenkins send mail system configuration
- Getting started with 3D modeling for games, what modeling software can I choose?
- 数据类型及输入输出初探(C语言)
- 软件测试面试题:手工测试与自动测试有哪些区别?
- 【Valentine's Day special effects】--Canvas realizes full screen love
- Senior game modelers tell newbies, what are the necessary software for game scene modelers?
- 软件测试面试题:软件测试类型都有哪些?
猜你喜欢

2022 Niu Ke Summer Multi-School Training Camp 5 (BCDFGHK)

2 用D435i运行VINS-fusion

leetcode:266. 回文全排列

KT148A voice chip ic working principle and internal architecture description of the chip

Modelers experience sharing: model study method

进程间通信和线程间通信
![Couple Holding Hands [Greedy & Abstract]](/img/7d/1cafc000dc58f1c5e2e92150be7953.png)
Couple Holding Hands [Greedy & Abstract]

Mathematical Principles of Matrix

gorm联表查询-实战

【LeetCode】双指针题解汇总
随机推荐
【数据挖掘概论】数据挖掘的简单描述
Mathematical Principles of Matrix
软件测试面试题:LoadRunner 分为哪三个模块?
Huggingface入门篇 II (QA)
测试经理要不要做测试执行?
软件测试面试题:您以往所从事的软件测试工作中,是否使用了一些工具来进行软件缺陷(Bug)的管理?如果有,请结合该工具描述软件缺陷(Bug)跟踪管理的流程?
what?测试/开发程序员要被淘汰了?年龄40被砍到了32?一瞬间,有点缓不过神来......
软件测试面试题:手工测试与自动测试有哪些区别?
软件测试面试题:请你分别画出 OSI 的七层网络结构图和 TCP/IP 的四层结构图?
【论文笔记】—低照度图像增强—Unsupervised—EnlightenGAN—2019-TIP
元宇宙:未来我们的每一个日常行为是否都能成为赚钱工具?
After another 3 days, I have sorted out 90 NumPy examples, and I can't help but bookmark it!
Mysql based
【idea】idea配置sql格式化
tiup telemetry
gorm联表查询-实战
2022杭电多校训练第三场 1009 Package Delivery
英特尔WiFi 7产品将于2024年亮相 最高速度可达5.8Gbps
2022多校第二场 K题 Link with Bracket Sequence I
软件测试面试题:黑盒测试、白盒测试以及单元测试、集成测试、系统测试、验收测试的区别与联系?