当前位置:网站首页>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;
}
边栏推荐
- MAUI Blazor 权限经验分享 (定位,使用相机)
- 软件测试面试题:黑盒测试、白盒测试以及单元测试、集成测试、系统测试、验收测试的区别与联系?
- 典型相关分析CCA计算过程
- 国内网站用香港服务器会被封吗?
- tiup telemetry
- Mysql based
- 2022牛客多校训练第二场 H题 Take the Elevator
- STC89C52RC的P4口的应用问题
- 2022牛客多校第三场 J题 Journey
- Software testing interview questions: test life cycle, the test process is divided into several stages, and the meaning of each stage and the method used?
猜你喜欢

SV 类的虚方法 多态
![[idea] idea configures sql formatting](/img/89/98cd23aff3e2f15ecb489f8b3c50e9.png)
[idea] idea configures sql formatting

【LeetCode】Summary of Two Pointer Problems

First, the basic concept of reptiles

How to automatically push my new articles to my fans (very simple, can't learn to hit me)

leetcode: 266. All Palindromic Permutations

3. Actual combat---crawl the result page corresponding to Baidu's specified entry (a simple page collector)

leetcode:266. 回文全排列

node使用redis
![[Cloud Native--Kubernetes] Pod Controller](/img/e1/1a8cc82223f9a9be79ebbf1211e9a4.png)
[Cloud Native--Kubernetes] Pod Controller
随机推荐
2022 Hangzhou Electric Power Multi-School Session 3 Question L Two Permutations
LeetCode Hot 100
软件测试面试题:BIOS, Fat, IDE, Sata, SCSI, Ntfs windows NT?
.net (C#) get year month day between two dates
MAUI Blazor 权限经验分享 (定位,使用相机)
进程间通信和线程间通信
子连接中的参数传递
Mysql_13 事务
GO中sync包自由控制并发的方法
tiup update
E - Many Operations (按位考虑 + dp思想记录操作后的结果
2022 Hangzhou Electric Multi-School 1004 Ball
jenkins send mail system configuration
"No title"
【Unity编译器扩展之进度条】
日志(logging模块)
Brainstorm: Complete Backpack
tiup telemetry
软件测试面试题:手工测试与自动测试有哪些区别?
Will domestic websites use Hong Kong servers be blocked?