link

题意:

有 n 道题,每个题可以做很多次但只能领悟一次,一开没有领悟任何题。

对于第 i 个题,正确率为 $p_i$ 。领悟之前,做对这个题可以提升 $a_i$ 的能力值;领悟之后,做对这个题可以提升 $b_i$ 的能力值。(保证 $a_i<b_i$ )

做对一个题,还可以领悟任意一个题(任选)。做错题后,什么都不会发生。

现在可以做 t 次题(同一题算多次),问最大能力值? $n\leq 10^5,t\leq 10^{10}$

题解:

【一些吐槽】 由于考试数据水现场各种水过。大家都猜了一个错误的结论:领悟之前和之后都各只做一道题。

事实上领悟之后确实是只做一道题,选的一定是 $b_ip_i$ 最大的那个题,记这个值为 $mx$ ,但领悟之前就不是了,需要 dp 。

设 $f_t$ 表示 t 时刻的最大能力值,方程$$\begin{aligned}f_{t+1}&=\max \{p_i\times (a_i+mx\times t)+(1-p_i)\times f_t\}\\f_{t+1}&=\max \{p_ia_i+p_i\times(mx\times t-f_t)\}+f_t\end{aligned}$$

这里有个性质:由于一轮的贡献不会超过 mx ,所以有$$\begin{aligned}f_{t+1}-f_t &\leq mx \\ \Longleftrightarrow t\times mx-f_t &\leq (t+1)\times mx-f_{t+1}\end{aligned}$$

即 $mx\times t-f_t$ 是单调不减的。

那么把 $p_ia_i$ 看成截距, $p_i$ 看成斜率, $f$ 的转移就相当于取若干一次函数的最大值,求下凸壳即可。 dp 的时候从左往右扫每条直线,用矩阵乘法和倍增优化转移。复杂度 $\mathcal{O}(n\log T)$ 。

code:

 #include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)
#define ll long long
#define db double using namespace std; const int N=1e5+;
int n,m; db mx,ans; ll t,cnt; const db eps=1e-;
const int dcmp(db x){return fabs(x)<eps?:x<-eps?-:;} struct line{
db k,b;
line(db k=,db b=):k(k),b(b){}
friend bool operator < (line x,line y){
return dcmp(x.k-y.k)==?dcmp(x.b-y.b)>:dcmp(x.k-y.k)<;
}
}p[N],q[N]; struct mat{
int n,m; db a[][];
mat(int n=,int m=):n(n),m(m){memset(a,,sizeof(a));}
friend mat operator * (mat x,mat y){
mat z(x.n,y.m);
rep (i,,z.n-)
rep (j,,z.m-)
rep (k,,x.m-) z.a[i][j]+=x.a[i][k]*y.a[k][j];
return z;
}
}A,B,trs[]; db inter_x(line x,line y){return (y.b-x.b)/(x.k-y.k);} int main(){
scanf("%d%lld",&n,&t);
rep (i,,n){
int a,b; db c;
scanf("%d%d%lf",&a,&b,&c);
mx=max(mx,b*c),p[i]=line(c,a*c);
}
sort(p+,p++n);
rep (i,,n) if (i==||dcmp(p[i].k-p[i-].k)!=) q[++m]=p[i];
n=;
rep (i,,m){
while (n>=&&dcmp(inter_x(q[i],p[n])-inter_x(p[n],p[n-]))<=) n--;
p[++n]=q[i];
}
cnt=;
A=mat(,); A.a[][]=;
for (int i=;i<=n&&cnt<t;i++){
db R=mx*cnt-A.a[][];
while (i<n&&dcmp(inter_x(p[i],p[i+])-R)<=) i++;
if (i<n) R=inter_x(p[i],p[i+]);
trs[]=mat(,);
trs[].a[][]=-p[i].k,trs[].a[][]=p[i].k*mx,trs[].a[][]=p[i].b;
trs[].a[][]=trs[].a[][]=trs[].a[][]=;
rep (j,,) trs[j]=trs[j-]*trs[j-];
for (int j=;~j;j--)
if (cnt+(1ll<<j)<t){
B=trs[j]*A;
if (i==n||dcmp((cnt+(1ll<<j))*mx-B.a[][]-R)<=) A=B,cnt+=1ll<<j;
}
cnt++,A=trs[]*A;
}
printf("%.10lf\n",A.a[][]);
return ;
}

CF1067D Computer Game的更多相关文章

  1. [CF1067D]Computer Game[凸包/斜率优化+倍增+矩阵乘法]

    题意 你有 \(n\) 个任务,初始收益为 \(a\) ,共 \(t\) 轮游戏,每轮可以选择完成一个任务(可以做多次),完成之后可以给任意任务升级,升级之后的任务收益为 \(b\) ,每个任务还有完 ...

  2. CF1067D. Computer Game(斜率优化+倍增+矩阵乘法)

    题目链接 https://codeforces.com/contest/1067/problem/D 题解 首先,如果我们获得了一次升级机会,我们一定希望升级 \(b_i \times p_i\) 最 ...

  3. 共享文件夹:The user has not been granted the requested logon type at this computer

    场景重现 今天做一个项目测试,要用到虚拟机,于是在虚拟机(XP 32)上新建了一个共享的文件夹.然后我在Win7 机器上访问它得到如下的error 消息:

  4. Computer assisted surgery

    Computer assisted surgery (CAS) represents a surgical concept and set of methods, that use computer ...

  5. Computer vision labs

    积累记录一些视觉实验室,方便查找 1.  多伦多大学计算机科学系 2.  普林斯顿大学计算机视觉和机器人实验室 3.  牛津大学Torr Vision Group 4.  伯克利视觉和学习中心 Pro ...

  6. Computer Vision: OpenCV, Feature Tracking, and Beyond--From <<Make Things See>> by Greg

    In the 1960s, the legendary Stanford artificial intelligence pioneer, John McCarthy, famously gave a ...

  7. 数论 - Vanya and Computer Game

    Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level ...

  8. A Taxonomy of Computer Organizations

    COMPUTER OR GANIZATION AND ARCHITECTURE DESIGNING FOR PERFORMANCE NINTH EDITION

  9. [转载]Three Trending Computer Vision Research Areas, 从CVPR看接下来几年的CV的发展趋势

    As I walked through the large poster-filled hall at CVPR 2013, I asked myself, “Quo vadis Computer V ...

随机推荐

  1. Redis实战(八)Redis的配置文件介绍

    https://www.cnblogs.com/ysocean/p/9074787.html

  2. js 语法高亮插件之 Prism.js

    之前也介绍过几款语法高亮插件<为博客园选择一个小巧霸气的语法高亮插件>以及关于他们的综合性能<再议 语法高亮插件的选择>.今天在小影志博客看到<使用 Prism.js 实 ...

  3. 40个新鲜的 jQuery 插件,使您的网站用户友好

    作为最流行的 JavaScript 开发框架,jQuery 在现在的 Web 开发项目中扮演着重要角色,它简化了 HTML 文档遍历,事件处理,动画以及 Ajax 交互,这篇文章特别收集了40个新鲜的 ...

  4. 转载 python多重继承C3算法

    备注:O==object 2.python-C3算法解析: #C3 定义引用开始 C3 算法:MRO是一个有序列表L,在类被创建时就计算出来. L(Child(Base1,Base2)) = [ Ch ...

  5. 关于v4包的Fragment过渡动画的事件监听无响应问题解决

    项目中部分功能模块采用了单Activity+多Fragment模式,当Fragment切换时,需要在过渡动画执行完后做一些操作,通常就是在自己封装的FragmentBase中重写onCreateAni ...

  6. tensorboard遇到的坑

    <ul><li>No graph definition files were found.</li></ul> <p>启动命令 tensor ...

  7. Shell-遍历删除指定目录

    Code: find $LibPath/ -name .svn | xargs rm -rf

  8. thymeleaf-extras-shiro

    thymeleaf-extras-shiro 转载:https://github.com/theborakompanioni/thymeleaf-extras-shiro A Thymeleaf di ...

  9. linux服务器安装anaconda,然后远程使用jupyter

    linux服务器安装anaconda: 1.1 下载安装脚本: wget https://repo.anaconda.com/archive/Anaconda3-5.2.0-Linux-x86_64. ...

  10. 使用配置文件启动MongoDB

    Ubuntu 16.04 (阿里云ECS),MongoDB 4.0, 原来,已经写了10篇MongoDB的随笔了.可是,自己居然没有使用配置文件启动过MongoDB,对其更多的配置是不明白的. 昨天( ...