码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • 状压dp+二分


    Problem Description

    Finally, Little Q gets his weapon at level 10^5105 in the RPG game, now he is trying to beat the boss as soon as possible. The boss has HH units of health point (HP), Little Q needs to cause at least HH units of damage to beat the boss.

    Little Q has learnt nn skills, labeled by 1,2,\dots,n1,2,…,n. Each skill can not be used multiple times, because there is not enough time for Little Q to wait for the skill to cool down. Assume Little Q uses the ii-th skill at the xx-th frame, the actor controlled by him will take t_iti​ frames to perform, which means Little Q will not be allowed to use other skills until the (x+t_i)(x+ti​)-th frame. The length of the damage sequence of the ii-th skill is len_ileni​, which means the skill will cause d_{i,j}di,j​ (0\leq j < len_i0≤j

    The game starts at the 00-th frame. Your task is to help Little Q beat the boss as soon as possible, or determine Little Q can't beat the boss using all the skills at most once.

    1. #include
    2. #include
    3. #include
    4. using namespace std;
    5. typedef long long ll;
    6. const int N=19,M=1e5+5;
    7. ll f[1<
    8. ll d[N][M];
    9. int t[N],len[N];
    10. int p[1<
    11. int n;ll h;
    12. bool check(int x)
    13. {
    14. for(int i=0;i<(1<
    15. {
    16. int sum=0;
    17. f[i]=0;
    18. for(int j=0;j
    19. {
    20. if((i>>j)&1)
    21. {
    22. int now=p[i]-t[j+1];
    23. if(x-now+1>=1&&x-now+1<=len[j+1])
    24. f[i]=max(f[i],f[i^(1<1][x-now+1]);
    25. else if(x-now+1>len[j+1])f[i]=max(f[i],f[i^(1<1][len[j+1]]);
    26. else f[i]=max(f[i],f[i^(1<
    27. }
    28. }
    29. }
    30. return (f[(1<-1]>=h);
    31. }
    32. void solve()
    33. {
    34. scanf("%d%lld",&n,&h);
    35. for(int i=1;i<=n;i++)
    36. {
    37. scanf("%d%d",&t[i],&len[i]);
    38. for(int j=1;j<=len[i];j++)
    39. {
    40. scanf("%lld",&d[i][j]);
    41. d[i][j]+=d[i][j-1];
    42. }
    43. }
    44. for(int i=0;i<(1<
    45. {
    46. p[i]=0;
    47. for(int j=0;j
    48. {
    49. if((i>>j)&1) p[i]+=t[j+1];
    50. }
    51. }
    52. int l=0,r=2e6;
    53. int ans=-1;
    54. while(l<=r)
    55. {
    56. int m=(l+r)/2;
    57. if(check(m))
    58. {
    59. ans=m;
    60. r=m-1;
    61. }
    62. else l=m+1;
    63. }
    64. printf("%d\n",ans);
    65. }
    66. int main()
    67. {
    68. int t;
    69. scanf("%d",&t);
    70. while(t--)
    71. {
    72. solve();
    73. }

  • 相关阅读:
    PSI项目介绍
    2022年您应该考虑使用的最佳WordPress主题
    Azure 开发者新闻快讯丨开发者8月大事记一览
    Linux学习笔记(7)
    SpringCloud微服务实战——搭建企业级开发框架(四十三):多租户可配置的电子邮件发送系统设计与实现
    JVM之safepoint
    第05篇:手写JavaRPC框架之执行层思路
    交换机和路由器基础
    虾皮shopee电商数据平台官方API接口根据商品ID获取商品产品详情返回值说明
    实战4 - 汽车行驶工况构建
  • 原文地址:https://blog.csdn.net/qq_52004482/article/details/126041733
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号