• 状压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. }

  • 相关阅读:
    分布式事务两阶段提交和三阶段提交有什么区别?
    async-validator 源码学习(一):文档翻译
    178. 分数排名
    现有的 NFT 协议
    操作符一些代码题
    AI大模型探索之路-实战篇13: 从对话到报告:打造能记录和分析的Agent智能数据分析平台
    2 OpenCV实现的F矩阵+RANSAC原理与实践
    OpenTDF 客户端cpp版本SDK的编译和使用
    青海2022农民丰收节 国稻种芯:河湟第七届农产品展交会
    TCP连接
  • 原文地址:https://blog.csdn.net/qq_52004482/article/details/126041733